https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97617
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> --- The warning is documented to be done only for loops that don't have multiple exits (because otherwise it would have too many false positives; when the loop isn't guaranteed to loop 16 times, there might not be an UB). As printf is a possible cancellation point, it isn't marked throw() in the C headers, so if you compile with C++ and don't turn off exceptions, the result is expected - there are EH edges out of the printf call that might terminate the loop.