Testcase:
int[0] arr;
void main()
{
auto a = arr;
}
Yields:
test.o: In function `_Dmain':
test.d:(.text._Dmain+0x16): undefined reference to `_D4test3arrG0i'
collect2: ld returned 1 exit status
--- errorlevel 1
Most likely cause I guess is incorrect mangling.
Regards
Comment #1 by ibuclaw — 2010-12-09T05:45:27Z
Actually, it's something else. DMD doesn't output var declarations that have no size.
Patch to always write out globals:
--- dmd~/toobj.c 2010-11-19 22:39:05.011906002 +0000
+++ dmd/toobj.c 2010-12-09 13:29:19.672718003 +0000
@@ -1287,7 +1287,7 @@
else
s->Sseg = DATA;
#endif
- if (sz)
+ if (1 || sz)
{ outdata(s);
if (isExport())
obj_export(s,0);
Regards
Comment #7 by bearophile_hugs — 2012-05-20T05:29:04Z
Maybe related to Issue 7997
Comment #8 by hsteoh — 2014-07-12T05:07:23Z
Seems to have been fixed in git HEAD. Tested on Linux 64-bit, dmd revision 2cd115bb6738e884c19b32b1640b23ed25efc0d6. Please reopen if this still happens.
Comment #9 by hsteoh — 2014-07-12T05:08:23Z
Gah, nevermind, missed the note about fix only working for ELF.