This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/17910] wrong order of static initialization
- From: "jason at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 8 Nov 2009 23:24:43 -0000
- Subject: [Bug c++/17910] wrong order of static initialization
- References: <bug-17910-2109@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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