[Bug c++/70515] Nested lambdas causing invalid captured pointers on some platforms
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70515 Jason Merrill changed: What|Removed |Added Status|NEW |RESOLVED CC||jason at gcc dot gnu.org Resolution|--- |INVALID --- Comment #7 from Jason Merrill --- lambda2 captures lambda1 by reference, and is then copied into func. When their block ends lambda1 no longer exists, so the reference in func is dangling, and so invoking it has undefined behavior.
[Bug c++/70515] Nested lambdas causing invalid captured pointers on some platforms
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70515 Paolo Carlini changed: What|Removed |Added Priority|P3 |P2 CC|gcc at norgg dot org |
[Bug c++/70515] Nested lambdas causing invalid captured pointers on some platforms
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70515 Martin Sebor changed: What|Removed |Added Status|WAITING |NEW Known to fail||5.3.1, 6.3.0, 7.0 --- Comment #6 from Martin Sebor --- Thank you. I still can't reproduce the problem with -O0 but I do see a SIGSEGV on x86_64 when I compile the test case with -O1 or higher, with all of GCC 5.x, 6.x, and 7.0. Thus confirmed. $ /ssd/build/gcc-6-branch/gcc/xg++ -B /ssd/build/gcc-6-branch/gcc -nostdinc++ -I /ssd/build/gcc-6-branch/x86_64-pc-linux-gnu/libstdc++-v3/include/x86_64-pc-linux-gnu -I /ssd/build/gcc-6-branch/x86_64-pc-linux-gnu/libstdc++-v3/include -I /src/gcc/6-branch/libstdc++-v3/libsupc++ -I /src/gcc/6-branch/libstdc++-v3/include/backward -I /src/gcc/6-branch/libstdc++-v3/testsuite/util -L /ssd/build/gcc-6-branch/x86_64-pc-linux-gnu/libstdc++-v3/src/.libs -std=gnu++1z -g -O1 t.C && gdb -batch -q -ex r -ex bt a.out Program received signal SIGSEGV, Segmentation fault. 0x0040064c in::operator() (__closure=0x7fffde68) at t.C:9 9 auto lambda1 = [&]{ (*j)++; }; #0 0x0040064c in ::operator() (__closure=0x7fffde68) at t.C:9 #1 ::operator() (__closure=0x7fffdea0, __closure@entry=0x7fffde30) at t.C:10 #2 std::_Function_handler >::_M_invoke(const std::_Any_data &) (__functor=...) at /ssd/build/gcc-6-branch/x86_64-pc-linux-gnu/libstdc++-v3/include/functional:1731 #3 0x004006bf in std::function::operator()() const (this=0x7fffdea0) at /ssd/build/gcc-6-branch/x86_64-pc-linux-gnu/libstdc++-v3/include/functional:2127 #4 main () at t.C:16
[Bug c++/70515] Nested lambdas causing invalid captured pointers on some platforms
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70515 --- Comment #5 from Norgg --- Created attachment 40994 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=40994=edit gcc -v output for gcc 6.2.0
[Bug c++/70515] Nested lambdas causing invalid captured pointers on some platforms
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70515 Norgg changed: What|Removed |Added CC||gcc at norgg dot org --- Comment #4 from Norgg --- Created attachment 40993 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=40993=edit gcc -v output for gcc 5.4.0 (In reply to Martin Sebor from comment #3) > I also cannot reproduce it with 7.0 on powepc64le or with 5.x on x86_64. > Can you please list the processor architectures you see this problem on? > (Providing the output of gcc -v should help.) I can still reproduce this on my x86_64 Ubuntu system, in both g++ 5.4.1 and 6.2.0, gcc -v output from each attached.
[Bug c++/70515] Nested lambdas causing invalid captured pointers on some platforms
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70515 Martin Sebor changed: What|Removed |Added Status|UNCONFIRMED |WAITING Last reconfirmed||2017-03-16 CC||msebor at gcc dot gnu.org Ever confirmed|0 |1 --- Comment #3 from Martin Sebor --- I also cannot reproduce it with 7.0 on powepc64le or with 5.x on x86_64. Can you please list the processor architectures you see this problem on? (Providing the output of gcc -v should help.)
[Bug c++/70515] Nested lambdas causing invalid captured pointers on some platforms
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70515 --- Comment #2 from Andrew Pinski --- Can't reproduce this on aarch64-linux-gnu with GCC 6.1.0.
[Bug c++/70515] Nested lambdas causing invalid captured pointers on some platforms
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70515 Andrew Pinski changed: What|Removed |Added Keywords||wrong-code Severity|major |normal
[Bug c++/70515] Nested lambdas causing invalid captured pointers on some platforms
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70515 --- Comment #1 from Norgg --- Created attachment 38164 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=38164=edit Preprocessed file