class A {}; class B { static A *A; }; A *B::A = 0; g++3.4-20040317 compiles code without errors. g++3.3 reports error: declaration of `A*B::A' changes meaning of `A' from `class A' which behavior is correct?
Subject: Re: New: declaration of `A*B::A' changes meaning of `A' from `class A'... "pluto at ds14 dot agh dot edu dot pl" <gcc-bugzilla@gcc.gnu.org> writes: | class A {}; | class B { | static A *A; | }; | A *B::A = 0; | | g++3.4-20040317 compiles code without errors. | g++3.3 reports error: declaration of `A*B::A' changes meaning of `A' from | `class A' | | which behavior is correct? The code is ill-formed. No diagnostic is required. GCC used to diagnose that in the past. This is a regression. I would think it is a serious one (a frequent mistake). -- Gaby
Hm, I may be blind today, but I fail to see what may be wrong with this code? (Clearly the initialization of the member has nothing to do with the problem here.) Gaby, do you refer to the "after declaration, reevaluate the declaration with the newly defined name and see whether it is still valid" rule? Or what do you refer to in saying that the code is invalid? W.
Subject: Re: [3.4/3.5 Regression] declaration of `A*B::A' changes meaning of `A' from `class A'... "bangerth at dealii dot org" <gcc-bugzilla@gcc.gnu.org> writes: | Hm, I may be blind today, but I fail to see what may be wrong with this | code? (Clearly the initialization of the member has nothing to do with | the problem here.) Yes, I was not talking about the initialization. | Gaby, do you refer to the "after declaration, reevaluate | the declaration with the newly defined name and see whether it is still | valid" rule? Yes, that is the one I was referring to. -- Gaby
OK, this is most likely a regression with the new parser then. Thanks W.
Working on a fix.
Subject: Bug 14668 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_4-branch Changes by: mmitchel@gcc.gnu.org 2004-05-28 20:12:12 Modified files: gcc/testsuite : ChangeLog gcc/cp : ChangeLog parser.c gcc/testsuite/g++.old-deja/g++.benjamin: tem04.C Added files: gcc/testsuite/g++.dg/lookup: redecl1.C Log message: PR c++/14668 * parser.c (cp_parser_simple_type_specifier): Call maybe_note_name_used_in_class. PR c++/14668 * g++.dg/lookup/redecl1.C: New test. * g++.old-deja/g++.benjamin/tem04.C: Add error marker. Patches: 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.184&r2=1.3389.2.185 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.106&r2=1.3892.2.107 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/parser.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.157.2.28&r2=1.157.2.29 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/lookup/redecl1.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.old-deja/g++.benjamin/tem04.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.7&r2=1.7.16.1
Subject: Bug 14668 CVSROOT: /cvs/gcc Module name: gcc Changes by: mmitchel@gcc.gnu.org 2004-05-28 20:16:03 Modified files: gcc/cp : parser.c gcc/testsuite/g++.old-deja/g++.benjamin: tem04.C Added files: gcc/testsuite/g++.dg/lookup: redecl1.C Log message: PR c++/14668 * parser.c (cp_parser_simple_type_specifier): Call maybe_note_name_used_in_class. PR c++/14668 * g++.dg/lookup/redecl1.C: New test. * g++.old-deja/g++.benjamin/tem04.C: Add error marker. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/parser.c.diff?cvsroot=gcc&r1=1.195&r2=1.196 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/lookup/redecl1.C.diff?cvsroot=gcc&r1=1.1&r2=1.2 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.old-deja/g++.benjamin/tem04.C.diff?cvsroot=gcc&r1=1.7&r2=1.8
Subject: Bug 14668 CVSROOT: /cvs/gcc Module name: gcc Changes by: mmitchel@gcc.gnu.org 2004-05-28 20:17:22 Modified files: gcc/cp : ChangeLog gcc/testsuite : ChangeLog Log message: PR c++/14668 * parser.c (cp_parser_simple_type_specifier): Call maybe_note_name_used_in_class. PR c++/14668 * g++.dg/lookup/redecl1.C: New test. * g++.old-deja/g++.benjamin/tem04.C: Add error marker. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4062&r2=1.4063 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.3785&r2=1.3786
Fixed in GCC 3.4.1.