D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 19523 - "undefined identifier" causes DMD crash
Summary: "undefined identifier" causes DMD crash
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 regression
Assignee: basile-z
URL:
Keywords: pull
Depends on:
Blocks:
 
Reported: 2018-12-30 12:15 UTC by KytoDragon
Modified: 2020-03-21 03:56 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description KytoDragon 2018-12-30 12:15:13 UTC
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 basile-z 2019-02-14 05:18:32 UTC
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 basile-z 2019-02-14 05:27:27 UTC
reg 2.079 or 2.079.1 actually
Comment 3 basile-z 2019-02-14 06:22:06 UTC
pull : https://github.com/dlang/dmd/pull/9360
Comment 4 Dlang Bot 2019-02-15 19:08:37 UTC
dlang/dmd pull request #9364 "Merge remote-tracking branch 'upstream/stable' into merge_stable" was merged:

https://github.com/dlang/dmd/pull/9364