digitalmars.D.bugs - [Issue 4237] New: Link error with typedefs of the same name in a function scope
- d-bugmail puremagic.com (57/57) May 26 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4237
- d-bugmail puremagic.com (39/39) May 28 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4237
- d-bugmail puremagic.com (16/16) May 28 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4237
- d-bugmail puremagic.com (16/16) May 28 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4237
- d-bugmail puremagic.com (8/20) Oct 10 2011 http://d.puremagic.com/issues/show_bug.cgi?id=4237
- d-bugmail puremagic.com (13/13) Oct 11 2011 http://d.puremagic.com/issues/show_bug.cgi?id=4237
http://d.puremagic.com/issues/show_bug.cgi?id=4237 Summary: Link error with typedefs of the same name in a function scope Product: D Version: 2.041 Platform: x86 OS/Version: All Status: NEW Keywords: link-failure Severity: normal Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: rsinfu gmail.com --- Typedefs in function scope don't get fully mangled with scope information. As a result, the following code won't link: -------------------- test.d struct Struct(T) { T value; } void main() { { typedef int Number = 1; Struct!Number s; pragma(msg, "1: ", typeof(s).mangleof); } { typedef real Number = 2; Struct!Number s; pragma(msg, "2: ", typeof(s).mangleof); } } -------------------- On Linux and FreeBSD: -------------------- 1: S4test20__T6StructTT6NumberZ6Struct 2: S4test20__T6StructTT6NumberZ6Struct test.o(.rodata+0x18): multiple definition of `_Dmain6Number6__initZ' test.o(.rodata+0x14): first defined here -------------------- On Windows: -------------------- 1: S4test20__T6StructTT6NumberZ6Struct 2: S4test20__T6StructTT6NumberZ6Struct 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 0027DH Record Type 0091 Error 1: Previous Definition Different : _Dmain6Number6__initZ --- errorlevel 1 -------------------- -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
May 26 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4237 Shin Fujishiro <rsinfu gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |patch Summary|Link error with typedefs of |Typedefs of the same name |the same name in a function |cause initializer conflict |scope | --- Still the problem exists. As shown in the output example below, the two distinct typedefs get mangled to the same name. Then the assertion fails due to the corrupted initial value. -------------------- test.d struct Struct(T) { T value; } void foo() { typedef int Number = 1; Struct!Number s; pragma(msg, typeof(s).mangleof); assert(s.value == 1); } void bar() { typedef real Number = 2; Struct!Number s; pragma(msg, typeof(s).mangleof); assert(s.value == 2); // Assertion failure } void main() { foo(); bar(); } -------------------- % dmd -run test S4test20__T6StructTT6NumberZ6Struct S4test20__T6StructTT6NumberZ6Struct core.exception.AssertError test(14): Assertion failure -------------------- -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
May 28 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4237 --- Here's a trivial patch to dmd svn r502. --- src/declaration.c +++ src/declaration.c -296,6 +296,7 Dsymbol *TypedefDeclaration::syntaxCopy(Dsymbol *s) void TypedefDeclaration::semantic(Scope *sc) { //printf("TypedefDeclaration::semantic(%s) sem = %d\n", toChars(), sem); + parent = sc->parent; if (sem == 0) { sem = 1; basetype = basetype->semantic(loc, sc); -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
May 28 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4237 --- --- src/declaration.c +++ src/declaration.c -298,6 +298,7 void TypedefDeclaration::semantic(Scope *sc) //printf("TypedefDeclaration::semantic(%s) sem = %d\n", toChars(), sem); if (sem == 0) { sem = 1; + parent = sc->parent; basetype = basetype->semantic(loc, sc); sem = 2; #if DMDV2 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
May 28 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4237--- src/declaration.c +++ src/declaration.c -298,6 +298,7 void TypedefDeclaration::semantic(Scope *sc) //printf("TypedefDeclaration::semantic(%s) sem = %d\n", toChars(), sem); if (sem == 0) { sem = 1; + parent = sc->parent; basetype = basetype->semantic(loc, sc); sem = 2; #if DMDV2Pushed as pull request: https://github.com/D-Programming-Language/dmd/pull/445 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 10 2011
http://d.puremagic.com/issues/show_bug.cgi?id=4237 Walter Bright <bugzilla digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |bugzilla digitalmars.com Resolution| |FIXED 15:01:46 PDT --- https://github.com/D-Programming-Language/dmd/commit/1cc61cbccf64c65c3257326a1df02519c06808c1 https://github.com/D-Programming-Language/dmd/commit/a6586474a8cc7ae92f13afabfeffcaa5ac085d1d -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 11 2011