Bug 12271 – Undefined reference linker error with __traits(compiles) that returns false.
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-02-26T17:50:00Z
Last change time
2015-03-30T06:18:08Z
Assigned to
nobody
Creator
opantm2+dbugs
Comments
Comment #0 by opantm2+dbugs — 2014-02-26T17:50:47Z
I haven't been able to reduce this further, and while I assume it's the __traits(compiles) that causes this, I could be wrong.
Note that the __traits(compiles) should always fail.
Sample:
struct Symbol {
}
struct TypeMetadata {
}
void createMetadata(Type)() {
if(__traits(compiles, getType!Type)) { }
}
void getType(T)() {
Symbol = getSymbol!T;
}
Symbol getSymbol(Args...)() {
Symbol result();
return result;
}
void main() {
createMetadata!TypeMetadata;
}
Output:
ogivm:~$ rdmd -v test.d
binary /usr/bin/dmd
version v2.065-devel-0f04b0b
config /usr/bin/dmd.conf
parse test
importall test
import object (/home/kapps/dev/druntime/import/object.di)
semantic test
entry main test.d
semantic2 test
semantic3 test
code test
function D main
function test.createMetadata!(TypeMetadata).createMetadata
function test.getSymbol!(TypeMetadata).getSymbol
gcc /tmp/.rdmd-1000/rdmd-test.d-65EE17DBD03E4141D553B0B773C006B9/objs/test.o -o /tmp/.rdmd-1000/rdmd-test.d-65EE17DBD03E4141D553B0B773C006B9/test.tmp -m64 -L/usr/lib/x86_64-linux-gnu -L/usr/lib/i386-linux-gnu -Xlinker --no-warn-search-mismatch -Xlinker --export-dynamic -l:libphobos2.a -lpthread -lm -lrt
/tmp/.rdmd-1000/rdmd-test.d-65EE17DBD03E4141D553B0B773C006B9/objs/test.o: In function `_D4test35__T9getSymbolTS4test12TypeMetadataZ9getSymbolFNaZS4test6Symbol':
test.d:(.text._D4test35__T9getSymbolTS4test12TypeMetadataZ9getSymbolFNaZS4test6Symbol+0x8): undefined reference to `_D4test35__T9getSymbolTS4test12TypeMetadataZ9getSymbolFNaZS4test6Symbol6resultMFZS4test6Symbol'
collect2: error: ld returned 1 exit status
--- errorlevel 1
Comment #1 by opantm2+dbugs — 2015-03-30T06:18:08Z