Bug 44991 - [4.4/4.5/4.6 Regression] default argument with '<' cause compilation error
Summary: [4.4/4.5/4.6 Regression] default argument with '<' cause compilation error
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.5.0
: P2 normal
Target Milestone: 4.4.5
Assignee: Jason Merrill
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2010-07-19 15:20 UTC by Olivier Goffart
Modified: 2010-08-30 13:39 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work: 4.1.2 4.3.4
Known to fail: 4.4.0
Last reconfirmed: 2010-08-26 06:09:53


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Olivier Goffart 2010-07-19 15:20:22 UTC
class bar {
    void foo(bool a = 3 < 2, bool b = true) {}
};

$ g++ -c ./main.cpp
./main.cpp:2:39: error: redefinition of 'bool b'
./main.cpp:2:39: error: 'bool b' previously declared here


(This happends only if the funciton is a member function)
Comment 1 Jonathan Wakely 2010-07-19 15:38:28 UTC
confirmed, this worked with gcc 4.1
Comment 2 Jakub Jelinek 2010-08-25 10:00:17 UTC
Caused by r140120 (i.e. PR37302), guess the declaration is now added during tentative parsing which is then not committed and parsed again differently, defining the parameter again.
Comment 3 Jason Merrill 2010-08-29 19:24:49 UTC
Subject: Bug 44991

Author: jason
Date: Sun Aug 29 19:24:37 2010
New Revision: 163629

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=163629
Log:
	PR c++/44991
	* parser.c (cp_parser_parameter_declaration): Pop parameter decls
	after tentative parsing.

Added:
    trunk/gcc/testsuite/g++.dg/parse/defarg15.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/parser.c
    trunk/gcc/testsuite/ChangeLog

Comment 4 Jason Merrill 2010-08-30 13:37:56 UTC
Subject: Bug 44991

Author: jason
Date: Mon Aug 30 13:37:34 2010
New Revision: 163643

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=163643
Log:
	PR c++/44991
	* parser.c (cp_parser_parameter_declaration): Pop parameter decls
	after tentative parsing.

Added:
    branches/gcc-4_5-branch/gcc/testsuite/g++.dg/parse/defarg15.C
Modified:
    branches/gcc-4_5-branch/gcc/cp/ChangeLog
    branches/gcc-4_5-branch/gcc/cp/parser.c
    branches/gcc-4_5-branch/gcc/testsuite/ChangeLog

Comment 5 Jason Merrill 2010-08-30 13:38:30 UTC
Subject: Bug 44991

Author: jason
Date: Mon Aug 30 13:38:09 2010
New Revision: 163644

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=163644
Log:
	PR c++/44991
	* parser.c (cp_parser_parameter_declaration): Pop parameter decls
	after tentative parsing.

Added:
    branches/gcc-4_4-branch/gcc/testsuite/g++.dg/parse/defarg15.C
Modified:
    branches/gcc-4_4-branch/gcc/cp/ChangeLog
    branches/gcc-4_4-branch/gcc/cp/parser.c
    branches/gcc-4_4-branch/gcc/testsuite/ChangeLog

Comment 6 Jason Merrill 2010-08-30 13:39:20 UTC
Fixed.