“this” captured by lambda is incorrect. GCC compiler bug?

前端 未结 2 1543
温柔的废话
温柔的废话 2021-01-01 16:53

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:

  • The
相关标签:
2条回答
  • 2021-01-01 17:00

    This seems to be a compiler bug in gcc 6.2, see:

    https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77686

    Workarounds:

    • Use -fno-schedule-insns2 flag (as pointed out by gbmhunter, see comment below).
    • Do not use -O2 optimizations or higher.
    0 讨论(0)
  • 2021-01-01 17:02

    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).

    0 讨论(0)
提交回复
热议问题