digitalmars.D.bugs - [Issue 4616] New: Link error with copy constructor of nested struct
- d-bugmail puremagic.com (46/47) Aug 10 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4616
- d-bugmail puremagic.com (27/27) Dec 17 2012 http://d.puremagic.com/issues/show_bug.cgi?id=4616
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 puremagic.com ReportedBy: rsinfu gmail.com --- 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.dOPTLINK (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: -------
Aug 10 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4616 Dmitry S <ds.dlang gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |ds.dlang gmail.com This no longer seems to be reproducible. With dmd compiled from the current head, the following code (a bit more involved to test it better) compiles and works (on MacOSX): import std.stdio; struct S { struct N { S s; this(this) { s.value += 1; } } int value = 17; } int main() { S.N n1; S.N n2 = n1; writefln("%d %d", n1.s.value, n2.s.value); return 0; } Prints "17 18". -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Dec 17 2012