[Bug c++/32534] gcc fails to initialize template's static data members before their use in some cases

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu Nov 3 18:47:00 GMT 2011


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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID

--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-11-03 18:47:32 UTC ---
Indeed, [basic.start.init] p2 says so, thanks.

An ordering could be enforced by explicitly specializing the static data
member:
  template<> A B<int>::a = A();
or in C++11
  template<> A B<int>::a{};

Or in C++11 by making A's constructor constexpr



More information about the Gcc-bugs mailing list