The code: class A { A ( int n=0 int n ); }; compiles in G++-3.4, but shouldn't, as I understand it.
Confirmed a regression from 3.3.1, also note it is even worse than that. this is accepted: struct A { A ( int n=0 ,int n1 ); }; And this is too: struct A { A ( int n=0 i ); }; Looks the parser is ignorning anything after the default argument until the ')' token.
Subject: Bug 14361 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_4-branch Changes by: mmitchel@gcc.gnu.org 2004-03-02 02:00:06 Modified files: gcc/cp : ChangeLog decl.c parser.c pt.c gcc/testsuite : ChangeLog gcc/testsuite/g++.old-deja/g++.ns: koenig5.C Added files: gcc/testsuite/g++.dg/parse: defarg7.C gcc/testsuite/g++.dg/template: friend26.C Log message: PR c++/14360 * parser.c (cp_parser_postfix_expression): Do not perform Koenig lookup if ordinary name-lookup finds a non-function. * pt.c (tsubst_copy_and_build): Likewise. PR c++/14361 * parser.c (cp_parser_late_parsing_default_args): Check that there are no extra tokens after the end of the default-argument expression. Backport 2004-02-12 Mark Mitchell <mark@codesourcery.com> * decl.c (redeclaration_error_message): Correct handling of templates. * pt.c (tsubst_friend_declaration): Adjust code to determine whether or not a friend template is a definition. (tsubst_decl): Clear DECL_INITIAL for new FUNCTION_DECLs. 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.65&r2=1.3892.2.66 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.10&r2=1.1174.2.11 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.17&r2=1.157.2.18 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.816.2.15&r2=1.816.2.16 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.115&r2=1.3389.2.116 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/parse/defarg7.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++.dg/template/friend26.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++.ns/koenig5.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3&r2=1.3.16.1
Subject: Bug 14361 CVSROOT: /cvs/gcc Module name: gcc Changes by: mmitchel@gcc.gnu.org 2004-03-02 02:06:18 Modified files: gcc/cp : ChangeLog parser.c pt.c gcc/testsuite : ChangeLog gcc/testsuite/g++.old-deja/g++.ns: koenig5.C Added files: gcc/testsuite/g++.dg/parse: defarg7.C gcc/testsuite/g++.dg/template: friend26.C Log message: PR c++/14360 * parser.c (cp_parser_postfix_expression): Do not perform Koenig lookup if ordinary name-lookup finds a non-function. * pt.c (tsubst_copy_and_build): Likewise. PR c++/14361 * parser.c (cp_parser_late_parsing_default_args): Check that there are no extra tokens after the end of the default-argument expression. PR c++/14360 * g++.old-deja/g++.ns/koenig5.C: Remove some error markers. PR c++/14361 * g++.dg/parse/defarg7.C: New test. PR c++/14359 * g++.dg/template/friend26.C: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.3981&r2=1.3982 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/parser.c.diff?cvsroot=gcc&r1=1.178&r2=1.179 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&r1=1.834&r2=1.835 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.3560&r2=1.3561 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/parse/defarg7.C.diff?cvsroot=gcc&r1=1.1&r2=1.2 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/friend26.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++.ns/koenig5.C.diff?cvsroot=gcc&r1=1.3&r2=1.4
Fixed in GCC 3.4 and GCC 3.5.