correction: prob with extern name for static local vbl of inline fn on alpha
scott snyder
snyder@d0sgif.fnal.gov
Tue May 12 16:43:00 GMT 1998
hi -
The bug report i sent in a couple days ago had a problem in the test case
(was including the wrong header).
This version corrects that problem.
thanks,
sss
hi -
I saw this problem with the egcs-1.0.3 prerelease on a Digital Unix
4.0b system (an alpha). It was also present in a recent snapshot
(19980425).
The problem is that sometimes, for an inline template function with a local
static variable, gcc will generate a module-local assembler name for
the static variable, preventing it from being shared properly between
modules.
Here's an example:
-- t.hpp --------------------------------------------------------------------
template <class T>
class T2
{
public:
static void* d0om_type_static ()
{
static void* d0om_T2_type;
return d0om_T2_type;
};
};
template <class T>
class d0_Ref
{
public:
void ptr1 () const;
};
template <class T>
void d0_Ref<T>::ptr1() const
{
T2<int>::d0om_type_static ();
}
-- t1.cpp -------------------------------------------------------------------
#include "t.hpp"
void bar (const d0_Ref<int>& r)
{
r.ptr1 ();
}
-- t2.cpp -------------------------------------------------------------------
#include "t.hpp"
static void d0om_type_setup ()
{
T2<int>::d0om_type_static ();
}
-----------------------------------------------------------------------------
I then compile and look at the external name generated for `d0om_T2_type':
$ gcc -S -c t1.cpp
$ gcc -S -c t2.cpp
$ grep 'comm.*d0om_T2_type' t*.s
t1.s: .lcomm d0om_T2_type.6,8
t2.s: .comm _Q2t2T21Zi27d0om_type_static__t2T21Zi.0$d0om_T2_type,8
For t1.cpp, it looks like the compiler used a module-local name for the
variable; thus it won't be properly shared with the instance generated
in t2.cpp.
So far, i've only seen this problem on the alpha; it does not appear
to be present on i386/linux and mips/irix platforms.
thanks,
sss
More information about the Gcc-bugs
mailing list