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++/12222] New: explicit initialization of static template members seems ignored


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

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

           Summary: explicit initialization of static template members seems
                    ignored
           Product: gcc
           Version: 3.4
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: stefaandr at hotmail 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

Shouldn't this code output 1234?  It outputs 0 for me.  I used to write
b a<float>::b1 instead of template <> b a<float>::b1, but
I tried this after seeing comment 3 on bug 11930.  I can even
change the constructor of b into a non-default one and it still compiles...

using g++-3.4 (GCC) 3.4 20030907 (experimental)

#include <iostream>
struct b {
  b() { m = 1234; }; int m;
};
template <class T>
  struct a { static b b1; };
template struct a<float>;
template <> b a<float>::b1;
int main() {
  std::cout << a<float>::b1.m << std::endl;
};


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