| www.delorie.com/djgpp/bugs/show.cgi | search |
// 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;
}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.| webmaster donations bookstore | delorie software privacy |
| Copyright © 2010 by DJ Delorie | Updated Jul 2010 |