www.delorie.com/djgpp/bugs/show.cgi   search  
Bug 000356

When Created: 08/22/2002 12:44:05
Against DJGPP version: 2.03
By whom: spamjunk@stny.rr.com
Abstract: compiling with -g causes multiple symbols of the same name to be created
// this code will fail the link stage when compiled with -g because
// two symbols called "_x" will be created.

template<int I>
struct foo {
};

template<>
struct foo<1> {
    static const int& val()
    {
        static const int x = 1;
        return x;
    }
};

template<>
struct foo<2> {
    static const int& val()
    {
        static const int x = 2;
        return x;
    }
};

int main()
{
    int x;

    x = foo<1>::val();

    x = foo<2>::val();

    return 0;
}

Note added: 10/14/2002 17:19:13
By whom: richdawe@bigfoot.com
I reproduced this problem with:

* gcc 3.0
* gcc 3.1

I could not reproduce this problem with:

* gcc 2.95.3
* gcc 3.2

Using 'nm' on the generated object files showed
that gcc 3.0 & 3.1 generated unmangled names for
each member variable x, which is incorrect.

Some C++ ABI issues were addressed in the gcc 3.2
release. See:

    http://gcc.gnu.org/gcc-3.2/changes.html

This is a compiler problem rather than
a DJGPP-specific problem.

Closed on 10/15/2002 04:40:47: It's a bug in gcc (g++), not DJGPP.
By whom: richdawe@bigfoot.com



  webmaster     delorie software   privacy  
  Copyright © 2010   by DJ Delorie     Updated Jul 2010