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++/11094] New: incomplete static member breaks sizeof containing template class


PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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

           Summary: incomplete static member breaks sizeof containing
                    template class
           Product: gcc
           Version: 3.2.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: ncm@cantrip.org
                CC: gcc-bugs@gcc.gnu.org
 GCC build triplet: *-*-*
  GCC host triplet: x86-*-linux
GCC target triplet: *-*-*

For

  template<typename T> 
    struct Foo
    {
        int c;
        static int s[];
    };

  template<typename T>
    int Foo<T>::s[sizeof(Foo<T>)];

  int* p = Foo<char>::s;

I get

$ gcc -c t.cc
t.cc: In instantiation of `Foo<char>':
t.cc:11:   instantiated from here
t.cc:9: `sizeof' applied to incomplete type `Foo<char>'
t.cc:9: creating array with size zero (`0')
t.cc:11: `s' is not a member of type `Foo<char>'

See also http://gcc.gnu.org/ml/libstdc++/2003-04/msg00045.html
and related discussion.

If this gets fixed, note that this bug may have been worked 
around in the libstdc++ implementation, probably in 3.4; grep for
_Rep_base in include/bits/basic_string.h.



------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


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