https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118921
Bug ID: 118921 Summary: C++ frontend does not honor GCC pragma optimize Product: gcc Version: 15.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: tnfchris at gcc dot gnu.org Target Milestone: --- The following example: # pragma STDC FP_CONTRACT ON # if __GNUC__ >= 4 # pragma GCC optimize ("no-fast-math,fp-contract=on") # endif # ifdef __FAST_MATH__ # error Hey yo, What you doing on FAST_MATH?? # endif -- compiles with gcc -Ofast but not with g++ -Ofast, it looks like the macro does not get undefined for g++, but the pragma does get processed: #include <math.h> # pragma STDC FP_CONTRACT ON # if __GNUC__ >= 4 # pragma GCC optimize ("no-fast-math,fp-contract=off") # endif void foo (float *f, float *g, int n) { for (int i = 0; i < n; i++) f[i] += 2.6f * g[i]; } shows that for both GCC and G++ the FMA doesn't get formed. Is the pragma supposed to update the CPP define?