https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82677
--- Comment #7 from rguenther at suse dot de <rguenther at suse dot de> --- On Mon, 23 Oct 2017, infinity0 at pwned dot gg wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82677 > > --- Comment #6 from infinity0 at pwned dot gg --- > What I mean is, even if you do change GCC to fix the unintended optimisation, > other projects' code are *still wrong* - it's only correct if you can assume > the C compiler is optimising your code in a very specific way, that happens to > safe for the specific sorts of "side effects" that div instructions do. You still have to mark stmts with side-effects as volatile. Conditional side-effects are tricky to get correct of course.