https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108747
Bug ID: 108747
Summary: Optimization makes user mistake more dangerous when
optimization is disabled by flag -O0
Product: gcc
Version: og11 (devel/omp/gcc-11)
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: alireza at hexosys dot com
Target Milestone: ---
As we can see below link:
https://godbolt.org/z/ze3nhszxx
although the user had a mistake and create undefined behavior maybe he expected
it because of the -O0 flag, the compiler won't do anything smart and use div
for %. so he thinks his code will work correctly.
I think -the O0 flag means no smarty thing for the compiler.