https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109578
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> --- (In reply to Vincent Lefèvre from comment #2) > (In reply to Andrew Pinski from comment #1) > > We don't removing code before undefined behavior ... > > That is GCC does not know that printf does not have side effects. > > Then GCC is incorrect in bug 29968, because it does the division *before* > the printf. Or was a bug which has since been fixed. For sparc GCC 12.2.0 we get: sethi %hi(.LC0), %o0 call puts, 0 or %o0, %lo(.LC0), %o0 ta 5 Anyways maybe the issue with PR 29968 was a scheduling issue which was fixed later on that GCC didn't realize divide could trap.