https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63207
Bug ID: 63207 Summary: ICE in expand_expr_real_l when instantiating a template with a lambda that captures a const variable with a dependent initializer Product: gcc Version: 5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: st at quanttec dot com Compiling the following following code with the current trunk GCC results in an ICE. template <typename T> struct Base { T value; }; template <typename T> struct Test : Base<T> { T test() { const int x = this->value; return ([&]{ return x; })(); } }; int main() { Test<int> t; t.value = 0; return t.test(); } g++ test.cpp --std=c++11 -Wall test.cpp: In lambda function: test.cpp:10:28: warning: ‘x’ is used uninitialized in this function [-Wuninitialized] return ([&]{ return x; })(); ^ test.cpp:9:15: note: ‘x’ was declared here const int x = this->value; ^ test.cpp:10:28: internal compiler error: in expand_expr_real_1, at expr.c:9517 return ([&]{ return x; })(); ^ 0x8c96ba expand_expr_real_1(tree_node*, rtx_def*, machine_mode, expand_modifier, rtx_def**, bool) ../../gcc/gcc/expr.c:9517 0x8d0dea store_expr(tree_node*, rtx_def*, int, bool) ../../gcc/gcc/expr.c:5338 0x8d8e4b expand_assignment(tree_node*, tree_node*, bool) ../../gcc/gcc/expr.c:5124 0x7e3b33 expand_gimple_stmt_1 ../../gcc/gcc/cfgexpand.c:3274 0x7e3b33 expand_gimple_stmt ../../gcc/gcc/cfgexpand.c:3376 0x7e99d3 expand_gimple_basic_block ../../gcc/gcc/cfgexpand.c:5215 0x7eb86f execute ../../gcc/gcc/cfgexpand.c:5821