For the last few days, I have been debugging a weird issue involving lambdas in C++. I have reduced the problem down to the following symptoms:
This seems to be a compiler bug in gcc 6.2, see:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77686
Workarounds:
-fno-schedule-insns2
flag (as pointed out by gbmhunter, see comment below).-O2
optimizations or higher.Sounds like the following compiler bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77933 (which only effects code generated with O1 optimizations or higher).