This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

prob with extern name for static local vbl of inline fn on alpha



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 "myclasses5.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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]