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]
Other format: [Raw text]

[Bug c++/15721] New: [3.5.0 regression] template instantation omits static data members


Here is the test program:

template <typename T> class gnu_obj_2
{
  public:
    static int my_static;
};

template <typename T> int gnu_obj_2<T>::my_static = 117;

// instantiate templates explicitly so their static members will exist
template class gnu_obj_2 <int>;
template class gnu_obj_2 <long>;

int main ()
{
  gnu_obj_2 <int>  test_int;
  gnu_obj_2 <long> test_long;
  return 0;
}

I compile this program with "gcc -S -gstabs+".  Then I look in the generated
assembly code for the static data members gnu_obj_2<int>::my_static and
gnu_obj_2<long>::my_static.

(I don't think the -gstabs+ is important but I just happened to start with this
flag and have kept it all the way till now, sigh.  This code originally came
from the gdb test suite, gdb.cp/m-static.cc).

The explicit instantiations of gnu_obj_2<int> and gnu_obj_2<long> are supposed
to instantiate the static data members along with everything else, but they don't.

http://gcc.gnu.org/ml/gcc/2004-05/msg01394.html

The last working gcc was 2004-05-19 01:00:00 UTC and the first broken gcc was
2004-05-19 02:00:00 UTC.  The problem is with this patch:

http://gcc.gnu.org/ml/gcc-patches/2004-05/msg01157.html
IMA repairs: Don't use DECL_ASSEMBLER_NAME for a key in cgraph(take two)

I'll add three attachments: the test program; the last good assembly code; and
the first bad assembly code.

-- 
           Summary: [3.5.0 regression] template instantation omits static
                    data members
           Product: gcc
           Version: 3.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P1
         Component: c++
        AssignedTo: zack at codesourcery dot com
        ReportedBy: mec dot gnu at mindspring dot com
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15721


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