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++/17910] wrong order of static initialization



------- Comment #6 from jason at gcc dot gnu dot org  2009-11-08 23:24 -------
14.7.4.1 [temp.point] says:

...the point of instantiation for such a specialization immediately follows the
namespace scope declaration or definition that refers to the specialization.

So, the point of instantiation for B<int>::B(), and thus for B<int>::a, is
*after* the declaration of b, and therefore there's no reason to expect
B<int>::a to be initialized before b.

If you need B<int>::a to be initialized before b, you can provide an explicit
instantiation:

template A B<int>::a;
B<int> b;


-- 


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


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