GCC: program doesn't work with compilation option -O3

后端 未结 16 1582
感动是毒
感动是毒 2020-12-16 20:12

I\'m writing a C++ program that doesn\'t work (I get a segmentation fault) when I compile it with optimizations (options -O1, -O2, -O3, etc.), but it works just fine when I

16条回答
  •  爱一瞬间的悲伤
    2020-12-16 20:46

    As the updated question will show ;) , the problem exists with a std::vector. One common error with vectors is reserve()ing what should have been resize()d. As a result, you'd be writing outside array bounds. An optimizer may discard those writes.

提交回复
热议问题