Bug 12146 – Linker error with __xopCmp, __xopEq, TypeInfo

Status
RESOLVED
Resolution
DUPLICATE
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-02-12T16:56:00Z
Last change time
2015-06-09T05:15:10Z
Keywords
link-failure, pull
Assigned to
nobody
Creator
code

Comments

Comment #0 by code — 2014-02-12T16:56:35Z
cat > bar.d << CODE struct Bar { bool opCmp(ubyte val) { return false; } } CODE cat > foo.d << CODE import bar; struct Appender { Bar[] tokens; // references TypeInfo of Bar!(ubyte) // TypeInfo references __xopCmp } void main() { } CODE dmd -lib bar dmd foo bar.a ---- foo.o:(.data._D18TypeInfo_S3bar3Bar6__initZ+0x40): undefined reference to `_D3bar3Bar8__xopCmpFKxS3bar3BarKxS3bar3BarZi' ---- It seems, that during compilation of the bar lib the generated _xOpCmp function isn't emitted to the object file.
Comment #1 by code — 2014-02-12T17:19:55Z
Comment #2 by dlang-bugzilla — 2014-02-12T17:49:23Z
Looks like a duplicate of bug 12144.
Comment #3 by code — 2014-02-12T17:50:45Z
Also happens with a sensible opCmp, like int opCmp(const ref Bar) { return 0; } It must deviate from the default signature though, i.e. can't be int opCmp(const ref Bar) const { return 0; }
Comment #4 by code — 2014-02-12T17:52:30Z
*** This issue has been marked as a duplicate of issue 12144 ***
Comment #5 by code — 2014-02-13T05:41:47Z
I think we should try to solve this by only creating one TypeInfo per struct, but always generate it, when the struct is defined. If the TypeInfo is referenced somewhere else, it will need to link against the module that defined the struct.
Comment #6 by code — 2014-02-13T16:41:25Z
The root cause for this bug was, that the TypeInfo for structs can only be generated after semantic3 for that struct was run. This is not possible if the TypeInfo is needed during the obj generation pass, e.g. because it is referenced by an array TypeInfo. https://github.com/D-Programming-Language/dmd/pull/3255