https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66774
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> --- (In reply to contact from comment #0) > As the bug does not > occur with -O0 I assume the bug is part of gcc, and not of my own code, but > I could obviously be wrong. This is a completely invalid assumption. Many, many bugs appear harmless without optimisations, because "the code appears to work correctly" is just one possible outcome of undefined behaviour, but enabling optimisation can cause a different outcome with more obvious symptoms.