https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122113
Bug ID: 122113
Summary: internal compiler error: finish_expr_stmt at
cp/semantics.cc:1169 with anonymous union member
initialized by f(this)
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Keywords: ice-on-valid-code
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: attackerj1113 at gmail dot com
Target Milestone: ---
The following code causes ICE on x86-64 gcc since version 12.1 and still
reproducible on trunk:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
template<typename T> static auto* f(T *t) {
T u(*t);
return "initialized";
}
int main() {
union { char const *x = f(this); };
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Please check https://godbolt.org/z/41GnP8Mrc
Compiler Output:
<source>: In function 'int main()':
<source>:8:36: internal compiler error: in finish_expr_stmt, at
cp/semantics.cc:1169
8 | union { char const *x = f(this); };
| ^
0x28cabd8 diagnostics::context::diagnostic_impl(rich_location*,
diagnostics::metadata const*, diagnostics::option_id, char const*,
__va_list_tag (*) [1], diagnostics::kind)
???:0
0x28bfb0b internal_error(char const*, ...)
???:0
0xb0063a fancy_abort(char const*, int, char const*)
???:0
0xc04e78 cp_finish_decl(tree_node*, tree_node*, bool, tree_node*, int,
cp_decomp*)
???:0
0xbf0f01 shadow_tag(cp_decl_specifier_seq*)
???:0
0xd35b83 c_parse_file()
???:0
0xea5f99 c_common_parse_file()
???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
Compiler returned: 1