https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124012
Bug ID: 124012
Summary: ICE in gimplify_var_or_parm_decl, at gimplify.c:3426
when destructuring a type with std::meta::info member
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: boris.staletic at protonmail dot com
Target Milestone: ---
Doesn't happen always, but under specific conditions gcc hits this assert:
https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/gimplify.cc;h=a27dc46d88c35f78424d54864772a21372f8f047;hb=HEAD#l3426
Not sure if this bug should block pr-123615, so I won't mark it as such.
Test case:
```
void sink(char extra);
struct extra_attributes {
char rvp;
decltype(^^::) guards;
};
auto bind_function() {
constexpr auto [rvp, other] = extra_attributes{};
sink(rvp);
}
int main() { bind_function(); }
```
The stacktrace:
```
foo.cpp: In function ‘auto bind_function()’:
foo.cpp:9:5: internal compiler error: in gimplify_var_or_parm_decl, at
gimplify.cc:3426
9 | (void)sink(other);
| ^~~~~~~~~~~~~~~~~
0x2a8d9bf internal_error(char const*, ...)
../../gcc/diagnostic-global-context.cc:787
0xafe3cb fancy_abort(char const*, int, char const*)
../../gcc/diagnostics/context.cc:1812
0x8fda07 gimplify_var_or_parm_decl
../../gcc/gimplify.cc:3426
0x12096c9 gimplify_compound_lval
../../gcc/gimplify.cc:3549
0x11ff8fb gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
../../gcc/gimplify.cc:20350
0x1216bff gimplify_expr
../../gcc/gimplify.cc:21510
0x1216bff gimplify_arg(tree_node**, gimple**, unsigned long, bool)
../../gcc/gimplify.cc:3912
0x121734f gimplify_call_expr
../../gcc/gimplify.cc:4926
0x12005a9 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
../../gcc/gimplify.cc:20370
0x1200681 gimplify_stmt(tree_node**, gimple**)
../../gcc/gimplify.cc:8679
0x1200681 gimplify_cleanup_point_expr
../../gcc/gimplify.cc:8406
0x1200681 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
../../gcc/gimplify.cc:20800
0x12028f6 gimplify_stmt(tree_node**, gimple**)
../../gcc/gimplify.cc:8679
0x12008ab gimplify_statement_list
../../gcc/gimplify.cc:2294
0x12008ab gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
../../gcc/gimplify.cc:20852
0x12028f6 gimplify_stmt(tree_node**, gimple**)
../../gcc/gimplify.cc:8679
0x1203f9a gimplify_bind_expr
../../gcc/gimplify.cc:1689
0x1201580 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
../../gcc/gimplify.cc:20602
0x1226a60 gimplify_stmt(tree_node**, gimple**)
../../gcc/gimplify.cc:8679
0x1226a60 gimplify_body(tree_node*, bool)
../../gcc/gimplify.cc:21708
/usr/local/libexec/gcc/x86_64-pc-linux-gnu/16.0.1/cc1plus -quiet -v
-D_GNU_SOURCE foo.cpp -quiet -dumpdir a- -dumpbase foo.cpp -dumpbase-ext .cpp
-mtune=generic -march=x86-64 -std=c++26 -version -freflection -o
/tmp/ccCSLQhl.s
```
gcc -v output:
```
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-pc-linux-gnu/16.0.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../configure --enable-languages=c,c++ --disable-libgomp
--disable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 16.0.1 20260204 (experimental) (GCC)
COLLECT_GCC_OPTIONS='-freflection' '-std=c++26' '-v' '-shared-libgcc'
'-mtune=generic' '-march=x86-64' '-dumpdir' 'a-'
/usr/local/libexec/gcc/x86_64-pc-linux-gnu/16.0.1/cc1plus -quiet -v
-D_GNU_SOURCE foo.cpp -quiet -dumpdir a- -dumpbase foo.cpp -dumpbase-ext .cpp
-mtune=generic -march=x86-64 -std=c++26 -version -freflection -o
/tmp/ccCSLQhl.s
GNU C++26 (GCC) version 16.0.1 20260204 (experimental) (x86_64-pc-linux-gnu)
compiled by GNU C version 16.0.1 20260204 (experimental), GMP version
6.3.0, MPFR version 4.2.2, MPC version 1.3.1, isl version none
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
ignoring nonexistent directory
"/usr/local/lib/gcc/x86_64-pc-linux-gnu/16.0.1/../../../../x86_64-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/lib/gcc/x86_64-pc-linux-gnu/16.0.1/../../../../include/c++/16.0.1
/usr/local/lib/gcc/x86_64-pc-linux-gnu/16.0.1/../../../../include/c++/16.0.1/x86_64-pc-linux-gnu
/usr/local/lib/gcc/x86_64-pc-linux-gnu/16.0.1/../../../../include/c++/16.0.1/backward
/usr/local/lib/gcc/x86_64-pc-linux-gnu/16.0.1/include
/usr/local/include
/usr/local/lib/gcc/x86_64-pc-linux-gnu/16.0.1/include-fixed
/usr/include
End of search list.
Compiler executable checksum: 4abd451e2867af2d1d915a4be19338e2
```
That's a compiler from two days ago, but the same stacktrace can be seen on
godbolt with today's gcc.