This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
new-abi bug: names for local static vbl flags
- To: gcc-bugs at gcc dot gnu dot org
- Subject: new-abi bug: names for local static vbl flags
- From: scott snyder <snyder at fnal dot gov>
- Date: Sun, 26 Nov 2000 19:37:38 CST
- Reply-To: scott snyder <snyder at fnal dot gov>
hi -
I've run into a name mangling problem with the new ABI. The flag variable
used to control initialization of local static variables is not
distinguished by source file. Thus, one can get collisions between these
names across different source files.
Here's an example demonstrating this.
-- a.cc -----------------------------------------------------------
extern "C" int puts (const char*);
struct A { A() { puts ("a ctor");} };
static void a ()
{
static A aa;
}
void b () { a (); }
-- b.cc -----------------------------------------------------------
extern "C" int puts (const char*);
struct B { B() { puts ("b ctor");} };
static void a ()
{
static B aa;
}
extern void b ();
int main ()
{
a ();
b ();
return 0;
}
-------------------------------------------------------------------
If i compile and run this with a current version of gcc
(20001126, on a i686-pc-linux-gnu system), i get:
$ g++ -o b a.cc b.cc
$ ./b
b ctor
$
I.e., only one of the constructors got called.
If i use the old ABI instead, i get the expected result:
$ g++ -fno-new-abi -o b a.cc b.cc
$ ./b
b ctor
a ctor
$
If i look at the assembly code, i see that in both a.cc and b.cc,
gcc is using a symbol `_ZGVZ1avE2aa' to control whether or not the
local variable aa gets initialized.
thanks,
sss