extern "C" void abort(); struct A { static int i; A(){} ~A(){i++;if(i>1)abort();} }; int A::i = 0; A a; extern A a; int main() { return 0; }
Oh, it is a regression.
*** Bug 17977 has been marked as a duplicate of this bug. ***
I did not know how hard it would to generate a self contained testcase which is why I had asked you file one (I just decided to file one after I got a tescase).
*** Bug 17996 has been marked as a duplicate of this bug. ***
From the dup: Mark, I just checked, the regression indeed appears with your patch http://gcc.gnu.org/ml/gcc-cvs/2003-08/msg00621.html
Subject: Bug 17976 CVSROOT: /cvs/gcc Module name: gcc Changes by: mmitchel@gcc.gnu.org 2004-10-15 04:18:09 Modified files: gcc/cp : ChangeLog decl.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/g++.dg/init: dtor3.C Log message: PR c++/17976 * decl.c (cp_finish_decl): Do not call expand_static_init more than once for a single variable. PR c++/17976 * g++.dg/init/dtor3.C: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4433&r2=1.4434 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl.c.diff?cvsroot=gcc&r1=1.1313&r2=1.1314 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.4452&r2=1.4453 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/init/dtor3.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
Subject: Bug 17976 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_4-branch Changes by: mmitchel@gcc.gnu.org 2004-10-15 04:23:56 Modified files: gcc/cp : ChangeLog decl.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/g++.dg/init: dtor3.C Log message: PR c++/17976 * decl.c (cp_finish_decl): Do not call expand_static_init more than once for a single variable. PR c++/17976 * g++.dg/init/dtor3.C: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3892.2.169&r2=1.3892.2.170 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.1174.2.26&r2=1.1174.2.27 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3389.2.287&r2=1.3389.2.288 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/init/dtor3.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1
Fixed in GCC 3.4.3.