Bug 19523 – "undefined identifier" causes DMD crash

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2018-12-30T12:15:13Z
Last change time
2020-03-21T03:56:34Z
Keywords
pull
Assigned to
Basile-z
Creator
KytoDragon

Comments

Comment #0 by kytodragon — 2018-12-30T12:15:13Z
The following code crashes dmd: void bar () { SomeStruct s; // undifined struct foo({ return s; }); } void foo (int delegate() arg) {} this was discovered with ldc2 version 13.0 and confirmed using dmd version 2.079.0 on Windows 7 x64. Acording to run.dlang.org this also happens in all newer versions. DMD log: onlineapp.d(2): Error: undefined identifier SomeStruct Segmentation fault (core dumped) LDC2 log: onlineapp.d(2): Error: undefined identifier SomeStruct /dlang/ldc-1.12.0/bin/ldc2(_ZN4llvm3sys15PrintStackTraceERNS_11raw_ostreamE+0x1a)[0x2a4b53a] /dlang/ldc-1.12.0/bin/ldc2(_ZN4llvm3sys17RunSignalHandlersEv+0x35)[0x2a49c35] /dlang/ldc-1.12.0/bin/ldc2[0x2a49d4c] /lib/x86_64-linux-gnu/libpthread.so.0(+0x13150)[0x7f726cb57150] /dlang/ldc-1.12.0/bin/ldc2(_ZN7FuncExp9matchTypeEP4TypeP5ScopePPS_i+0x372)[0xb8d9d2] /dlang/ldc-1.12.0/bin/ldc2(_ZN14implicitConvTo14ImplicitConvTo5visitEP7FuncExp+0x20)[0xc2a6f0] /dlang/ldc-1.12.0/bin/ldc2(_ZN12TypeFunction9callMatchEP4TypeP5ArrayIP10ExpressionEiPPKc+0x539)[0xb26749] /dlang/ldc-1.12.0/bin/ldc2(_ZN25ExpressionSemanticVisitor5visitEP7CallExp+0x1308)[0xb8f828] /dlang/ldc-1.12.0/bin/ldc2(_ZN24StatementSemanticVisitor5visitEP12ExpStatement+0x62)[0xa933b2] /dlang/ldc-1.12.0/bin/ldc2(_ZN24StatementSemanticVisitor5visitEP17CompoundStatement+0x130)[0xa93bf0] /dlang/ldc-1.12.0/bin/ldc2(_ZN16Semantic3Visitor5visitEP15FuncDeclaration+0x160a)[0xac189a] /dlang/ldc-1.12.0/bin/ldc2(_ZN16Semantic3Visitor5visitEP6Module+0x95)[0xabff35] /dlang/ldc-1.12.0/bin/ldc2(_Z13mars_mainBodyR5ArrayIPKcES3_+0x14b5)[0xb2be35] /dlang/ldc-1.12.0/bin/ldc2(_Z7cppmainiPPc+0x1cc9)[0xd00439] /dlang/ldc-1.12.0/bin/ldc2(_D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ6runAllMFZv+0x50)[0x2b8dc20] /dlang/ldc-1.12.0/bin/ldc2(_d_run_main+0x1f6)[0x2b8da36] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf1)[0x7f726c2181c1] /dlang/ldc-1.12.0/bin/ldc2[0xa5b8a5] Error: Error executing /dlang/ldc-1.12.0/bin/ldc2: Segmentation fault (core dumped)
Comment #1 by b2.temp — 2019-02-14T05:18:32Z
There's an attempt to see if Terror (the return type of `{return s;}`) can be converted to `int`. I have dirty fix at late stage for this, i'll try to see if it can be prevented earlier, e.g when semantic of `{return s;}` is done, or maybe gag the error that indicates the unhelpful "_terror_".
Comment #2 by b2.temp — 2019-02-14T05:27:27Z
reg 2.079 or 2.079.1 actually
Comment #3 by b2.temp — 2019-02-14T06:22:06Z
Comment #4 by dlang-bot — 2019-02-15T19:08:37Z
dlang/dmd pull request #9364 "Merge remote-tracking branch 'upstream/stable' into merge_stable" was merged: https://github.com/dlang/dmd/pull/9364