https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98990
Bug ID: 98990 Summary: Internal compiler error when two overloaded functions return `auto &&` and one accepts an `auto` parameter Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: david at doublewise dot net Target Milestone: --- The following valid translation unit ``` constexpr int x = 0; constexpr auto && f() { return x; } constexpr auto && f(auto) { return x; } ``` causes gcc to crash with ``` <source>:6:25: internal compiler error: same canonical type node for different types 'auto&&' and 'auto&&' 6 | constexpr auto && f(auto) { | ^ 0x1ce6f09 internal_error(char const*, ...) ???:0 0x9c60ce comptypes(tree_node*, tree_node*, int) ???:0 0x78ef77 decls_match(tree_node*, tree_node*, bool) ???:0 0x7c003c cplus_decl_attributes(tree_node**, tree_node*, int) ???:0 0x79f277 grokdeclarator(cp_declarator const*, cp_decl_specifier_seq*, decl_context, int, tree_node**) ???:0 0x7a3916 start_function(cp_decl_specifier_seq*, cp_declarator const*, tree_node*) ???:0 0x8de23d c_parse_file() ???:0 0xa5b7c2 c_common_parse_file() ???:0 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <https://gcc.gnu.org/bugs/> for instructions. Compiler returned: 1 ``` See it live: https://godbolt.org/z/bnszYo This code was accepted in gcc 10.2, but it is rejected by the upcoming 11.0.