[Issue 4616] New: Link error with copy constructor of nested struct

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Aug 10 21:42:58 PDT 2010


http://d.puremagic.com/issues/show_bug.cgi?id=4616

           Summary: Link error with copy constructor of nested struct
           Product: D
           Version: D2
          Platform: x86
        OS/Version: All
            Status: NEW
          Keywords: link-failure
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: rsinfu at gmail.com


--- Comment #0 from Shin Fujishiro <rsinfu at gmail.com> 2010-08-10 21:42:57 PDT ---
If a struct N is nested inside another struct S and N has a field of type S,
then defining a copy constructor of N causes a linker error.

The error occurs only when N has a field of type S.

-------------------- test.d
struct S
{
    struct N
    {
        S s;
        this(this) {}   // error
    }
}
--------------------

The error on FreeBSD:
--------------------
% dmd test.d
test.o(.text._D4test1S1N8__cpctorMFKS4test1S1NZv+0x18): In function
`_D4test1S1N8__cpctorMFKS4test1S1NZv':
: multiple definition of `_D4test1S1N8__cpctorMFKS4test1S1NZv'
test.o(.text._D4test1S1N8__cpctorMFKS4test1S1NZv+0x0): first defined here
--------------------

The error on Windows:
--------------------
>dmd test.d
OPTLINK (R) for Win32  Release 8.00.2
Copyright (C) Digital Mars 1989-2009  All rights reserved.
http://www.digitalmars.com/ctg/optlink.html
test.obj(test)  Offset 00403H Record Type 00C3 
 Error 1: Previous Definition Different : _D4test1S1N8__cpctorMFKS4test1S1NZv
--------------------

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


More information about the Digitalmars-d-bugs mailing list