https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105839
Bug ID: 105839
Summary: internal compiler error: in tsubst_omp_for_iterator,
at cp/pt.cc:18122 (instantiate_pending_templates ->
instantiate_decl -> tsubst_lambda_expr)
Product: gcc
Version: 12.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libgomp
Assignee: unassigned at gcc dot gnu.org
Reporter: northon_patrick3 at yahoo dot ca
CC: jakub at gcc dot gnu.org
Target Milestone: ---
Created attachment 53079
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53079&action=edit
Result from -freport-bug
The code:
```
void test(const auto &b1)
{
const auto loopImpl = [&](auto&& fc)
{
#pragma omp parallel for
for(auto&& [v1, v2] : b1);
};
loopImpl([]{});
}
void test2()
{
int a[10];
test(a);
}
```
The command line:
```
g++ -fopenmp test.cpp
```
The error:
```
internal compiler error: in tsubst_omp_for_iterator, at cp/pt.cc:18126
11 | for(auto&& [v1, v2] : b1);
| ^~~
0x1ac4724 internal_error(char const*, ...)
???:0
0x663b55 fancy_abort(char const*, int, char const*)
???:0
0x81d054 tsubst_lambda_expr(tree_node*, tree_node*, int, tree_node*)
???:0
0x80614a tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
???:0
0x7fedbe instantiate_decl(tree_node*, bool, bool)
???:0
0x81e704 instantiate_pending_templates(int)
???:0
0x7173d1 c_parse_final_cleanups()
???:0
```
GCC is configured with:
```
configure --prefix=/opt/pat-gcc --libdir=/opt/pat-gcc/lib
--libexecdir=/opt/pat-gcc/lib --enable-languages=c,c++,lto --with-isl
--with-linker-hash-style=gnu --with-system-zlib --enable-__cxa_atexit
--enable-cet=auto --enable-checking=release --enable-clocale=gnu
--enable-default-pie --enable-default-ssp --enable-gnu-indirect-function
--enable-gnu-unique-object --enable-install-libiberty --enable-linker-build-id
--enable-lto --enable-multilib --enable-plugin --enable-shared
--enable-threads=posix --disable-libssp --disable-libstdcxx-pch
--disable-libunwind-exceptions --disable-werror
gdc_include_dir=/opt/pat-gcc/include/dlang/gdc
```
It happens from version 10.1 to latest commit at this date.
It no longer crash if:
- I don't use structured bindings.
- b1 isn't a template.
- I remove `auto&& fc`.