https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120557
Bug ID: 120557
Summary: ICE: tree check: expected record_type or union_type or
qual_union_type, have integer_type in
finish_non_static_data_member, at cp/semantics.cc:2809
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: iamanonymous.cs at gmail dot com
Target Milestone: ---
Target: x86_64
*******************************************************************************
The compiler produces an internal error during tree_check_failed when compiling
the provided code with the specified options.
The issue can also be reproduced on Compiler Explorer.
*******************************************************************************
OS and Platform:
# uname -a
Linux ubuntu 4.15.0-213-generic #224-Ubuntu SMP Mon Jun 19 13:30:12 UTC 2023
x86_64 x86_64 x86_64 GNU/Linux
*******************************************************************************
# g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/root/gdbtest/gcc/gcc-250601/libexec/gcc/x86_64-pc-linux-gnu/16.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc/configure --prefix=/root/gdbtest/gcc/gcc-250601
--enable-languages=c,c++ --disable-multilib --disable-bootstrap
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 16.0.0 20250601 (experimental) (GCC)
*******************************************************************************
Program:
#cat code.cpp
int do_thing(int x, int z) {
auto first = [&](int a) {
auto second = [&](this auto const& self, int b) -> int {
if (b > x) return x;
else return self(x / b);
};
return second(z * 5);
};
return first(x);
}
int main(int argc, char** argv) {
return do_thing(1, 1);
}
*******************************************************************************
Command Lines:
g++ code_0.cpp -std=c++11 -fdiagnostics-color=always -c -o code_0.o
<source>: In lambda function:
<source>:4:32: error: use of 'auto' in lambda parameter declaration only
available with '-std=c++14' or '-std=gnu++14'
4 | auto second = [&](this auto const& self, int b) -> int {
| ^~~~
<source>:4:44: error: a lambda with captures may not have an explicit object
parameter of an unrelated type
4 | auto second = [&](this auto const& self, int b) -> int {
| ~~~~~~~~~~~~~~~~~^~~~
<source>:4:44: warning: explicit object member function only available with
'-std=c++23' or '-std=gnu++23' [-Wc++23-extensions]
<source>: In lambda function:
<source>:5:21: internal compiler error: tree check: expected record_type or
union_type or qual_union_type, have integer_type in
finish_non_static_data_member, at cp/semantics.cc:2809
5 | if (b > x) return x;
| ^
0x282e045 diagnostic_context::diagnostic_impl(rich_location*,
diagnostic_metadata const*, diagnostic_option_id, char const*, __va_list_tag
(*) [1], diagnostic_t)
???:0
0x284f786 internal_error(char const*, ...)
???:0
0x9e4838 tree_check_failed(tree_node const*, char const*, int, char const*,
...)
???:0
0xc1ad7d add_capture(tree_node*, tree_node*, tree_node*, bool, bool, unsigned
int*)
???:0
0xc1b449 add_default_capture(tree_node*, tree_node*, tree_node*)
???:0
0xd97454 finish_id_expression(tree_node*, tree_node*, tree_node*, cp_id_kind*,
bool, bool, bool*, bool, bool, bool, bool, char const**, unsigned long)
???:0
0xd04073 c_parse_file()
???:0
0xe6bdd9 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
*******************************************************************************
Also ICE on trunk, compiler explorer:https://godbolt.org/z/ohfT4cEsc
*******************************************************************************