Thread overview
[Issue 3031] New: scoped static var conflicts while linking
May 27, 2009
davidl@126.com
Oct 23, 2010
Peter Alexander
Nov 17, 2010
Lukasz Wrzosek
Nov 18, 2010
Lukasz Wrzosek
Feb 18, 2012
Walter Bright
Jul 08, 2012
yebblies
May 27, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3031

           Summary: scoped static var conflicts while linking
           Product: D
           Version: 2.028
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: major
          Priority: P1
         Component: DMD
        AssignedTo: bugzilla@digitalmars.com
        ReportedBy: davidl@126.com


void func(int i)
{
    switch(i)
    {
        case 1:{static int j;break;}
        case 2:{static int j;break;}
    }
}

void main()
{
}

compile this you get the previous definition different error when you link it.


 Error 1: Previous Definition Different : _D4test4funcFiZv1ji

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 23, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3031


Peter Alexander <peter.alexander.au@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |peter.alexander.au@gmail.co
                   |                            |m
         OS/Version|Windows                     |All


--- Comment #1 from Peter Alexander <peter.alexander.au@gmail.com> 2010-10-23 12:39:50 PDT ---
Simpler test case:

----

void main()
{
    { static int foo; }
    { static int foo; }
}

$ rdmd test.d
ld: duplicate symbol _D4test4mainFZv3fooi in
/tmp/.rdmd/rdmd-test.d-801BCEFE1CAD8F2472CC2713A3BF5714/test.d.o and
/tmp/.rdmd/rdmd-test.d-801BCEFE1CAD8F2472CC2713A3BF5714/test.d.o
collect2: ld returned 1 exit status

----

Unfortunately I'm not sure whether this is supposed to be an error or not. Obviously D doesn't consider scope for the mangled names of static local variables, but if this is meant to be an error then it should be a compiler error, not linker error.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
November 17, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3031



--- Comment #2 from Lukasz Wrzosek <luk.wrzosek@gmail.com> 2010-11-17 12:12:50 PST ---
Created an attachment (id=817)
Fix for this bug.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
November 18, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3031


Lukasz Wrzosek <luk.wrzosek@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
 Attachment #817 is|0                           |1
           obsolete|                            |


--- Comment #3 from Lukasz Wrzosek <luk.wrzosek@gmail.com> 2010-11-18 15:08:29 PST ---
Created an attachment (id=819)
Once again fix added and marked (patch)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 18, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=3031


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla@digitalmars.com


--- Comment #4 from Walter Bright <bugzilla@digitalmars.com> 2012-02-18 13:37:50 PST ---
Pull request and more commentary:

https://github.com/D-Programming-Language/dmd/pull/721

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
July 08, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=3031


yebblies <yebblies@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|patch, wrong-code           |link-failure
                 CC|                            |yebblies@gmail.com
           Platform|x86                         |All
            Version|2.028                       |D1 & D2


--- Comment #5 from yebblies <yebblies@gmail.com> 2012-07-08 22:15:27 EST ---
Issue 5655 is the same sort of thing for lambdas.

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