Public bug reported:
From the versions installed on my machine, the bug occurs in g++ 10.2.0,
g++ 10.3.0 and g++ 11.1.0, the only argument in -std=c++2a. The code
works on version 9.3.0 with -std=c++2a and -fconcepts. I have also
compiled with clang++ 12.0.0 without problems. The bug occurs when two
or more classes declare a template friend function with a requires. The
return type, number of arguments, number of template parameters, and
condition for requires does not make any difference.Example:
class Foo
{
template <typename T>
friend void func() requires true;
};
class Bar
{
template <typename T>
friend void func() requires true;
};
This code results in the following error message:
internal compiler error: Segmentation fault
9 | friend void func() requires true;
| ^~~~
0xe30681 internal_error(char const*, ...)
???:0
0xf54144 duplicate_decls(tree_node*, tree_node*, bool, bool)
???:0
0xf5da9b pushdecl_namespace_level(tree_node*, bool)
???:0
0x109001a push_template_decl(tree_node*, bool)
???:0
0x151d391 do_friend(tree_node*, tree_node*, tree_node*, tree_node*,
overload_flags, bool)
???:0
0xfbfc27 grokdeclarator(cp_declarator const*, cp_decl_specifier_seq*,
decl_context, int, tree_node**)
???:0
0x1003fd4 grokfield(cp_declarator const*, cp_decl_specifier_seq*, tree_node*,
bool, tree_node*, tree_node*)
???:0
0x1492c03 c_parse_file()
???:0
0x148061e 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 <file:///usr/share/doc/gcc-11/README.Bugs> for instructions.
On g++-10.x the error is only
internal compiler error: Segmentation fault
9 | friend void func() requires true;
| ^~~~
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-10/README.Bugs> for instructions.
Whether the function actually exists does not have any impact. The error
message always points to the second definition, in this case Bar.
** Affects: gcc-11 (Ubuntu)
Importance: Undecided
Status: New
--
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1950053
Title:
Friend function with requires causes segfault
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/gcc-11/+bug/1950053/+subscriptions
--
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs