[Issue 24282] New: Error in the code is not detected by the compiler and only fails at the linking stage
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Dec 15 06:32:09 UTC 2023
https://issues.dlang.org/show_bug.cgi?id=24282
Issue ID: 24282
Summary: Error in the code is not detected by the compiler and
only fails at the linking stage
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: siarhei.siamashka at hotmail.com
Testcase:
import std.stdio, std.algorithm;
int dummyhash(string s) {
return 0;
}
void main() {
auto input = ["a", "b"];
input.map!(s => s.map!dummyhash).writeln;
}
The code is incorrect (the "map!" part shouldn't be there), but the compiler
can't see this and only the linker fails:
$ dmd-2.106.0 testcase.d
/usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld:
testcase.o: in function
`_D3std9algorithm9iteration__T3mapS_D8testcase9dummyhashFAyaZiZ__TQBkTQnZQBrFNaNbNiNfQBcZSQDjQDiQDb__T9MapResultS_DQDaQCuQCnTQCqZQBb':
testcase.d:(.text._D3std9algorithm9iteration__T3mapS_D8testcase9dummyhashFAyaZiZ__TQBkTQnZQBrFNaNbNiNfQBcZSQDjQDiQDb__T9MapResultS_DQDaQCuQCnTQCqZQBb[_D3std9algorithm9iteration__T3mapS_D8testcase9dummyhashFAyaZiZ__TQBkTQnZQBrFNaNbNiNfQBcZSQDjQDiQDb__T9MapResultS_DQDaQCuQCnTQCqZQBb]+0x30):
undefined reference to
`_D3std9algorithm9iteration__T9MapResultS_D8testcase9dummyhashFAyaZiTQgZQBq6__ctorMFNaNbNcNiNfQBfZSQDsQDrQDk__TQDdS_DQCwQCqQCjTQCmZQDx'
collect2: error: ld returned 1 exit status
Error: linker exited with status 1
Also it's interesting that this triggers an ICE for GDC with the old frontend:
$ gdc-11.3.0 testcase.d
d21: internal compiler error: in ErrorStatement, at d/dmd/statement.c:290
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://bugs.gentoo.org/> for instructions.
--
More information about the Digitalmars-d-bugs
mailing list