Bug 85249 - [11/12/13/14 Regression] ICE with invalid default parameter
Summary: [11/12/13/14 Regression] ICE with invalid default parameter
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 8.0
: P4 normal
Target Milestone: 11.5
Assignee: Not yet assigned to anyone
URL:
Keywords: error-recovery, ice-on-invalid-code
Depends on:
Blocks:
 
Reported: 2018-04-06 10:30 UTC by Volker Reichelt
Modified: 2023-07-07 10:33 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2021-11-24 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Volker Reichelt 2018-04-06 10:30:29 UTC
The following invalid code snippet triggers an ICE since GCC 4.8.0:

========================================
struct A
{
  void operator= (const A& = A());
  void foo(const A&);
};

void A::foo(const A& = A()) {}
========================================

bug.cc:3:33: error: 'void A::operator=(const A&)' cannot have default arguments
   void operator= (const A& = A());
                                 ^
bug.cc:7:27: internal compiler error: canonical types differ for identical types 'void (A::)(const A&)' and 'void (A::)(const A&)'
 void A::foo(const A& = A()) {}
                           ^
0x9dc198 comptypes(tree_node*, tree_node*, int)
	../../gcc/gcc/cp/typeck.c:1480
0x89241a duplicate_decls(tree_node*, tree_node*, bool)
	../../gcc/gcc/cp/decl.c:2226
0x899062 grokfndecl
	../../gcc/gcc/cp/decl.c:9099
0x8a95f0 grokdeclarator(cp_declarator const*, cp_decl_specifier_seq*, decl_context, int, tree_node**)
	../../gcc/gcc/cp/decl.c:12429
0x8ac476 start_function(cp_decl_specifier_seq*, cp_declarator const*, tree_node*)
	../../gcc/gcc/cp/decl.c:15299
0x93c891 cp_parser_function_definition_from_specifiers_and_declarator
	../../gcc/gcc/cp/parser.c:26711
0x93c891 cp_parser_init_declarator
	../../gcc/gcc/cp/parser.c:19501
0x944508 cp_parser_simple_declaration
	../../gcc/gcc/cp/parser.c:13049
0x945318 cp_parser_block_declaration
	../../gcc/gcc/cp/parser.c:12874
0x9492a2 cp_parser_declaration
	../../gcc/gcc/cp/parser.c:12772
0x9496b1 cp_parser_declaration_seq_opt
	../../gcc/gcc/cp/parser.c:12648
0x9499a4 cp_parser_translation_unit
	../../gcc/gcc/cp/parser.c:4563
0x9499a4 c_parse_file()
	../../gcc/gcc/cp/parser.c:39016
0xa49636 c_common_parse_file()
	../../gcc/gcc/c-family/c-opts.c:1132
Please submit a full bug report, [etc.]
Comment 1 Jakub Jelinek 2018-04-06 14:16:07 UTC
Started with r186346.
Comment 2 Jakub Jelinek 2018-10-26 10:22:33 UTC
GCC 6 branch is being closed
Comment 3 Richard Biener 2019-11-14 07:57:52 UTC
The GCC 7 branch is being closed, re-targeting to GCC 8.4.
Comment 4 Jakub Jelinek 2020-03-04 09:51:29 UTC
GCC 8.4.0 has been released, adjusting target milestone.
Comment 5 Jakub Jelinek 2021-05-14 09:50:21 UTC
GCC 8 branch is being closed.
Comment 6 Richard Biener 2021-06-01 08:11:11 UTC
GCC 9.4 is being released, retargeting bugs to GCC 9.5.
Comment 7 Richard Biener 2022-05-27 09:38:52 UTC
GCC 9 branch is being closed
Comment 8 Jakub Jelinek 2022-06-28 10:35:06 UTC
GCC 10.4 is being released, retargeting bugs to GCC 10.5.
Comment 9 Richard Biener 2023-07-07 10:33:44 UTC
GCC 10 branch is being closed.