Thread overview
[Issue 12146] New: Linker error with __xopCmp, __xopEq, TypeInfo
Feb 13, 2014
Martin Nowak
Feb 13, 2014
Martin Nowak
Feb 13, 2014
Vladimir Panteleev
Feb 13, 2014
Martin Nowak
Feb 13, 2014
Martin Nowak
Feb 13, 2014
Martin Nowak
Feb 14, 2014
Martin Nowak
February 13, 2014
https://d.puremagic.com/issues/show_bug.cgi?id=12146

           Summary: Linker error with __xopCmp, __xopEq, TypeInfo
           Product: D
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: link-failure
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: code@dawg.eu


--- Comment #0 from Martin Nowak <code@dawg.eu> 2014-02-12 16:56:35 PST ---
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.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 13, 2014
https://d.puremagic.com/issues/show_bug.cgi?id=12146



--- Comment #1 from Martin Nowak <code@dawg.eu> 2014-02-12 17:19:55 PST ---
I think this is caused by this change. https://github.com/D-Programming-Language/dmd/pull/2582/files#diff-ffa5582af7d723c487d4a11ac6743b85L739

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 13, 2014
https://d.puremagic.com/issues/show_bug.cgi?id=12146


Vladimir Panteleev <thecybershadow@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |thecybershadow@gmail.com


--- Comment #2 from Vladimir Panteleev <thecybershadow@gmail.com> 2014-02-13 03:49:23 EET ---
Looks like a duplicate of bug 12144.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 13, 2014
https://d.puremagic.com/issues/show_bug.cgi?id=12146



--- Comment #3 from Martin Nowak <code@dawg.eu> 2014-02-12 17:50:45 PST ---
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; }

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 13, 2014
https://d.puremagic.com/issues/show_bug.cgi?id=12146


Martin Nowak <code@dawg.eu> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |DUPLICATE


--- Comment #4 from Martin Nowak <code@dawg.eu> 2014-02-12 17:52:30 PST ---
*** This issue has been marked as a duplicate of issue 12144 ***

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 13, 2014
https://d.puremagic.com/issues/show_bug.cgi?id=12146



--- Comment #5 from Martin Nowak <code@dawg.eu> 2014-02-13 05:41:47 PST ---
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.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 14, 2014
https://d.puremagic.com/issues/show_bug.cgi?id=12146


Martin Nowak <code@dawg.eu> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull


--- Comment #6 from Martin Nowak <code@dawg.eu> 2014-02-13 16:41:25 PST ---
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

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------