https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70515
Bug ID: 70515 Summary: Nested lambdas causing invalid captured pointers on some platforms Product: gcc Version: 5.4.0 Status: UNCONFIRMED Severity: major Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: gcc at norgg dot org Target Milestone: --- Created attachment 38163 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=38163&action=edit Minimal testcase The attached code causes a segfault at runtime due to an invalid read when trying to dereference j on some platforms but not others across multiple versions of GCC. We can replicate this on various machines with: Ubuntu g++ 5.3.1 / 5.1.1 / 4.8.4 Gentoo g++ 5.3.0 But not on: OSX g++ 5.3.0 / 6.0.0 Debian g++ 5.3.1 The command line used to compile and run was: g++ -std=c++11 lambdabug.cpp -o lambdabug && ./lambdabug