Bug 18125 – crt_constructor name conflict

Status
RESOLVED
Resolution
INVALID
Severity
critical
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2017-12-25T06:27:13Z
Last change time
2017-12-30T14:23:52Z
Assigned to
No Owner
Creator
changlon

Comments

Comment #0 by changlon — 2017-12-25T06:27:13Z
============== file a.d ============ module a; extern(C) void printf(const char*, ...) @nogc pure nothrow @trusted ; pragma(crt_constructor) extern(C) void initProcess(){ printf("call a.m\n"); } extern(C) int main(){ printf("main\n"); return 0; } ================file b.d =================== module b; extern(C) void printf(const char*, ...) @nogc pure nothrow @trusted ; pragma(crt_constructor) extern(C) void initProcess(){ printf("call b.m\n"); } ================================== dmd a.d b.d -betterC ./a call a.m main It should output ./a call a.m call b.m main
Comment #1 by schveiguy — 2017-12-30T14:23:52Z
extern(C) functions have no mangling, so you either need to name them something different, or not use extern(C). What is happening here is that you have 2 symbols in the table named initProcess, and the linker discards one.