https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117106
Bug ID: 117106
Summary: ICE when a "deducing this" function with noexcept
specification is used before the class is complete
Product: gcc
Version: 15.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: iamsupermouse at mail dot ru
Target Milestone: ---
The following code causes an internal compiler error in GCC 14 and trunk:
https://gcc.godbolt.org/z/j5Y945fMq
struct A
{
int x;
void foo(this auto &&self) noexcept(noexcept(self.x)) {}
auto bar() -> decltype(foo()) {}
};
This results in the following error:
<source>: In instantiation of 'void A::foo(this auto:1&&) [with auto:1 =
A&]':
<source>:5:35: required from here
5 | auto bar() -> decltype(foo()) {}
| ~~~^~
<source>:4:14: internal compiler error: in tsubst_expr, at cp/pt.cc:21978
4 | void foo(this auto &&self) noexcept(noexcept(self.x)) {}
| ^~~
0x285c505 diagnostic_context::diagnostic_impl(rich_location*,
diagnostic_metadata const*, diagnostic_option_id, char const*, __va_list_tag
(*) [1], diagnostic_t)
???:0
0x28702e5 internal_error(char const*, ...)
???:0
0xa8b484 fancy_abort(char const*, int, char const*)
???:0
0xccfed2 maybe_instantiate_noexcept(tree_node*, int)
???:0
0xb8c2ea mark_used(tree_node*, int)
???:0
0xab6458 build_new_method_call(tree_node*, tree_node*, vec<tree_node*,
va_gc, vl_embed>**, tree_node*, int, tree_node**, int)
???:0
0xd17106 finish_call_expr(tree_node*, vec<tree_node*, va_gc, vl_embed>**,
bool, bool, int)
???:0
0xc989da c_parse_file()
???:0
0xdf0599 c_common_parse_file()
???:0
Worth noting that Clang emits a weird error on this code:
https://stackoverflow.com/q/79081096/2752075
error: exception specification is not available until end of class
definition