https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94392
Bug ID: 94392
Summary: Infinite loops are optimized away for C99
Product: gcc
Version: 10.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: krister.walfridsson at gmail dot com
Target Milestone: ---
Created attachment 48141
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48141&action=edit
Source code reproducing the issue
John Regehr noticed on twitter
(https://twitter.com/johnregehr/status/1244335355509129216) that trunk GCC
removes infinite loops for C99, as can be seen by
gcc -O3 -std=c99 fermat.c
This behavior was introduced by the introduction of -ffinite-loops being
enabled at -O2. This is fine for C11, but infinite loops do not invoke
undefined behavior in C99, so the optimization should not be enabled per
default for -std=c99.