http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58706
Bug ID: 58706
Summary: ICE with lambda in OpenMP for-loop
Product: gcc
Version: 4.9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: reichelt at gcc dot gnu.org
The following valid code snippet (compiled with "-std=c++11 -fopenmp") triggers
an ICE since GCC 4.5.0 (when lambdas were introduced):
===================================================
template<typename T> void foo()
{
#pragma omp for
for (T i = [](){ return 0; }(); i < 10; ++i)
;
}
void bar()
{
foo<int>();
}
===================================================
bug.cc: In instantiation of 'void foo() [with T = int]':
bug.cc:10:12: required from here
bug.cc:3:9: internal compiler error: Segmentation fault
#pragma omp for
^
0xb15dff crash_signal
../../gcc/gcc/toplev.c:335
0x6cabd2 contains_struct_check
../../gcc/gcc/tree.h:2787
0x6cabd2 finish_omp_for(unsigned int, tree_code, tree_node*, tree_node*,
tree_node*, tree_node*, tree_node*, tree_node*, tree_node*)
../../gcc/gcc/cp/semantics.c:6321
0x5aae3d tsubst_expr
../../gcc/gcc/cp/pt.c:13596
0x5a9db7 tsubst_expr
../../gcc/gcc/cp/pt.c:13384
0x5a6d69 instantiate_decl(tree_node*, int, bool)
../../gcc/gcc/cp/pt.c:19603
0x5e4c6f instantiate_pending_templates(int)
../../gcc/gcc/cp/pt.c:19715
0x6204c6 cp_write_global_declarations()
../../gcc/gcc/cp/decl2.c:4121
Please submit a full bug report, [etc.]