From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32224 invoked by alias); 18 Mar 2003 02:46:01 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 32180 invoked by uid 71); 18 Mar 2003 02:46:00 -0000 Date: Tue, 18 Mar 2003 02:46:00 -0000 Message-ID: <20030318024600.32178.qmail@sources.redhat.com> To: nobody@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, From: Gabriel Dos Reis Subject: Re: c++/10112: static data member is not correctly initialized Reply-To: Gabriel Dos Reis X-SW-Source: 2003-03/txt/msg01198.txt.bz2 List-Id: The following reply was made to PR c++/10112; it has been noted by GNATS. From: Gabriel Dos Reis To: "Giovanni Bajo" Cc: "Wolfgang Bangerth" , , , , Subject: Re: c++/10112: static data member is not correctly initialized Date: 18 Mar 2003 03:34:23 +0100 "Giovanni Bajo" writes: | ----- Original Message ----- | From: "Gabriel Dos Reis" | To: "Giovanni Bajo" | Cc: "Wolfgang Bangerth" ; | ; ; ; | | Sent: Tuesday, March 18, 2003 2:46 AM | Subject: Re: c++/10112: static data member is not correctly initialized |=20 |=20 | >From which parts of the standard did read that? |=20 | I was reading =A73.6.2p1 <> = in | this way. That paragraph speaks about initialisation of objects. It says nothing about the order of template instantiations and the order | Anyway, the bug is about the order of initialization between two static d= ata | members. Since instantiation of class templates does not affect | initialization of static data members (as per quoted paragraph), even if = you | instantiate the class templates before inizializing the data members, you | should respect the order of inizialization of the data members. Unless the instantiation of the class template uses the static data members.=20 | It seems to me that GCC is initializing the static data members because t= he | templates are instantiated, but this violates =A714.7.1p8. What you're missing is that your expression in the assertion introduces an indeterminism in the order of instantiation. It is the instantiation of the static data members that defines them, not just their mere -template- definition. What is happening is not far from the following scenario:=20 struct A {=20 int p; =20 A(int x) : p(x) { } };=20 struct B { static A a; static int p1; }; int B::p1 =3D a.p; A B::a(123); int main() { assert (B::a.p =3D=3D B::p1); }=20 -- Gaby