Bug 17976 – [3.4/4.0 Regression] Calls the dtor twice
Description Andrew Pinski 2004-10-13 18:38:45 UTC
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; }
Comment 1 Andrew Pinski 2004-10-13 18:41:54 UTC
Oh, it is a regression.
Comment 2 Andrew Pinski 2004-10-13 18:42:43 UTC
*** Bug 17977 has been marked as a duplicate of this bug. ***
Comment 3 Andrew Pinski 2004-10-13 18:46:17 UTC
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).
Comment 4 Andrew Pinski 2004-10-14 12:28:12 UTC
*** Bug 17996 has been marked as a duplicate of this bug. ***
Comment 5 Andrew Pinski 2004-10-14 12:28:54 UTC
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
Comment 6 CVS Commits 2004-10-15 04:18:42 UTC
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
Comment 7 CVS Commits 2004-10-15 04:24:02 UTC
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
Comment 8 Mark Mitchell 2004-10-15 04:25:12 UTC
Fixed in GCC 3.4.3.
Description Andrew Pinski 2004-10-13 18:38:45 UTC
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; }Comment 1 Andrew Pinski 2004-10-13 18:41:54 UTC
Comment 2 Andrew Pinski 2004-10-13 18:42:43 UTC
Comment 3 Andrew Pinski 2004-10-13 18:46:17 UTC
Comment 4 Andrew Pinski 2004-10-14 12:28:12 UTC
Comment 5 Andrew Pinski 2004-10-14 12:28:54 UTC
Comment 6 CVS Commits 2004-10-15 04:18:42 UTC
Comment 7 CVS Commits 2004-10-15 04:24:02 UTC
Comment 8 Mark Mitchell 2004-10-15 04:25:12 UTC