www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 3031] New: scoped static var conflicts while linking

reply d-bugmail puremagic.com writes:
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: -------
May 27 2009
next sibling parent d-bugmail puremagic.com writes:
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: -------
Oct 23 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
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: -------
Nov 17 2010
prev sibling parent d-bugmail puremagic.com writes:
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: -------
Nov 18 2010