https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69756
Bug ID: 69756 Summary: Passing a multidimensional variable-length array into a lambda (by reference) causes a segfault Product: gcc Version: 5.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: josutous at dodsi dot com Target Milestone: --- Version: gcc (GCC) 5.1.0, Ubuntu 14.04 LTS (virtual machine) gcc -v output: COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-unknown-linux-gnu/5.1.0/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: ../gcc-5.1.0/configure --enable-cxx --enable-lto --enable-ssp --with-isl=/usr/local --with-gmp=/usr/local --with-mpfr=/usr/local --with-mpc=/usr/local --enable-ld=yes --enable-gold=yes --prefix=/usr/local Thread model: posix gcc version 5.1.0 (GCC) command: g++ MWE.cpp -o mwe Output: MWE.cpp: In lambda function: MWE.cpp:6:38: internal compiler error: in expand_expr_real_1, at expr.c:9608 int output = array[i4][i5][i6]; ^ Please submit a full bug report, with preprocessed source if appropriate. See <http://gcc.gnu.org/bugs.html> for instructions. MWE.ii, generated by adding -save-temps to the command: # 1 "MWE.cpp" # 1 "<built-in>" # 1 "<command-line>" # 1 "/usr/include/stdc-predef.h" 1 3 4 # 1 "<command-line>" 2 # 1 "MWE.cpp" int main() { int i1 = 2, i2 = 3, i3 = 4; int array[i1][i2][i3]; auto lambda = [&]() { int i4 = 1, i5 = 2, i6 = 3; int output = array[i4][i5][i6]; }; lambda(); } Additional information: Problem also occurs with two indices (int array [i1][i2]), but not with one index (int array [i1]). Tested on gcc.godbolt.org with GCC version 5.3.0, problem still occurs with similar error message.