| Summary: | Gimplify throws error on method call from inside nested lambdas | ||
|---|---|---|---|
| Product: | gcc | Reporter: | Aaron Plavnick <aaron.plavnick> |
| Component: | c++ | Assignee: | Not yet assigned to anyone <unassigned> |
| Status: | RESOLVED FIXED | ||
| Severity: | major | CC: | gabravier, jason, ppluzhnikov |
| Priority: | P3 | Keywords: | c++-lambda |
| Version: | 4.9.1 | ||
| Target Milestone: | 5.3 | ||
| Host: | Target: | ||
| Build: | Known to work: | 5.2.1, 6.0 | |
| Known to fail: | 4.9.3 | Last reconfirmed: | 2014-08-27 00:00:00 |
| Bug Depends on: | |||
| Bug Blocks: | 54367, 67244 | ||
Confirmed.
#1 0x0000000000ba3fb8 in gimplify_var_or_parm_decl (expr_p=0x7ffff68356b0)
at /space/rguenther/src/svn/trunk/gcc/gimplify.c:1759
1759 gcc_assert (seen_error ());
(gdb) l
1754 if (TREE_CODE (decl) == VAR_DECL
1755 && !DECL_SEEN_IN_BIND_EXPR_P (decl)
1756 && !TREE_STATIC (decl) && !DECL_EXTERNAL (decl)
1757 && decl_function_context (decl) == current_function_decl)
1758 {
1759 gcc_assert (seen_error ());
1760 return GS_ERROR;
(gdb) p debug_tree (decl)
<var_decl 0x7ffff6831090 this
type <pointer_type 0x7ffff682a150
...
align 64 context <function_decl 0x7ffff682bc00 operator()>
value-expr <component_ref 0x7ffff67c3f30 type <pointer_type 0x7ffff682a150>
readonly
arg 0 <indirect_ref 0x7ffff682e660 type <record_type 0x7ffff682f150 __lambda0>
arg 0 <parm_decl 0x7ffff682c400 __closure>>
arg 1 <field_decl 0x7ffff68302f8 __this type <pointer_type 0x7ffff682a150>
used unsigned nonlocal decl_7 DI file t.ii line 11 col 18 size <integer_cst 0x7ffff66c4de0 64> unit size <integer_cst 0x7ffff66c4df8 8>
align 64 offset_align 128
offset <integer_cst 0x7ffff66c4e10 constant 0>
bit offset <integer_cst 0x7ffff66c4e58 constant 0> context <record_type 0x7ffff682af18 __lambda0> chain <type_decl 0x7ffff6813ed8 __lambda0>>>>
seems like un-nesting didn't work somehow?
Still broken in 4.9.2. For what it's worth, it compiles with the following modification [adding "this->" to the Foo call]:
template<typename T> class B
{
public:
void Foo() {}
void Bar()
{
[&]()
{
[&]() { this->Foo(); }();
}();
}
};
int main( int argc, char** argv )
{
B<int> b;
b.Bar();
return 0;
}
Without the "this->", it compiles in neither 4.9.2, nor 5.0.0.
*** Bug 58907 has been marked as a duplicate of this bug. *** *** Bug 67244 has been marked as a duplicate of this bug. *** *** Bug 58907 has been marked as a duplicate of this bug. *** Fixed for 5.3. (In reply to Jason Merrill from comment #8) > Fixed for 5.3. Well, 4.9.3 still ICEs. (In reply to Markus Trippelsdorf from comment #9) > (In reply to Jason Merrill from comment #8) > > Fixed for 5.3. > > Well, 4.9.3 still ICEs. Yes, but this isn't a regression. |
Here is a minimal code sample, the bug exists in 4.7.3, 4.8.2, and 4.9.1. I compiled with -std=c++11 -------------------------------------------- template< typename T > class B { public: void Foo() {} void Bar() { [&]() { [&]() { Foo(); }(); }(); } }; int main( int argc, char** argv ) { B<int> b; b.Bar(); return 0; } ---------------------- The compiler returns: main.cpp: In lambda function: main.cpp:11:34: internal compiler error: in gimplify_var_or_parm_decl, at gimplify.c:1741 [&]() { Foo(); }(); ^ 0x81b03d gimplify_var_or_parm_decl ../../../../src/gcc-4.9.1/gcc/gimplify.c:1741 0x81d931 gimplify_expr(tree_node**, gimple_statement_base**, gimple_statement_base**, bool (*)(tree_node*), int) ../../../../src/gcc-4.9.1/gcc/gimplify.c:8058 0x81cb40 gimplify_modify_expr ../../../../src/gcc-4.9.1/gcc/gimplify.c:4527 0x81d97a gimplify_expr(tree_node**, gimple_statement_base**, gimple_statement_base**, bool (*)(tree_node*), int) ../../../../src/gcc-4.9.1/gcc/gimplify.c:7627 0x820876 gimplify_stmt(tree_node**, gimple_statement_base**) ../../../../src/gcc-4.9.1/gcc/gimplify.c:5373 0x820a3a gimplify_and_add ../../../../src/gcc-4.9.1/gcc/gimplify.c:385 0x820a3a gimplify_init_ctor_eval ../../../../src/gcc-4.9.1/gcc/gimplify.c:3558 0x81c0f2 gimplify_init_constructor ../../../../src/gcc-4.9.1/gcc/gimplify.c:3904 0x81c98e gimplify_modify_expr_rhs ../../../../src/gcc-4.9.1/gcc/gimplify.c:4167 0x81ca64 gimplify_modify_expr ../../../../src/gcc-4.9.1/gcc/gimplify.c:4486 0x81d97a gimplify_expr(tree_node**, gimple_statement_base**, gimple_statement_base**, bool (*)(tree_node*), int) ../../../../src/gcc-4.9.1/gcc/gimplify.c:7627 0x81da18 gimplify_target_expr ../../../../src/gcc-4.9.1/gcc/gimplify.c:5304 0x81da18 gimplify_expr(tree_node**, gimple_statement_base**, gimple_statement_base**, bool (*)(tree_node*), int) ../../../../src/gcc-4.9.1/gcc/gimplify.c:7994 0x81e4b3 gimplify_addr_expr ../../../../src/gcc-4.9.1/gcc/gimplify.c:4833 0x81e4b3 gimplify_expr(tree_node**, gimple_statement_base**, gimple_statement_base**, bool (*)(tree_node*), int) ../../../../src/gcc-4.9.1/gcc/gimplify.c:7673 0x8235ba gimplify_call_expr ../../../../src/gcc-4.9.1/gcc/gimplify.c:2395 0x81db82 gimplify_expr(tree_node**, gimple_statement_base**, gimple_statement_base**, bool (*)(tree_node*), int) ../../../../src/gcc-4.9.1/gcc/gimplify.c:7598 0x820876 gimplify_stmt(tree_node**, gimple_statement_base**) ../../../../src/gcc-4.9.1/gcc/gimplify.c:5373 0x81dc0a gimplify_cleanup_point_expr ../../../../src/gcc-4.9.1/gcc/gimplify.c:5149 0x81dc0a gimplify_expr(tree_node**, gimple_statement_base**, gimple_statement_base**, bool (*)(tree_node*), int) ../../../../src/gcc-4.9.1/gcc/gimplify.c:7990