https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119845
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
double c = split_factor * a;
...
res.x = c-(c-a);
>not compliant with floating point standards
Kinda of.
If you use -std=c23 instead of the default of -std=gnu23 (assuming the trunk,
13 defaulted to -std=gnu17), you get -ffp-contract=off which does not allow
contracting over different statements (note -ffp-contract=on does still allows
it in the same statement; though this is across statements in this case).
If you don't want contraction in one location you can use
__builtin_assoc_barrier
Like:
double c = __builtin_assoc_barrier(split_factor * a);
This will stop the contraction with `-ffp-contract=fast` option.
See
https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html#index-_005f_005fbuiltin_005fassoc_005fbarrier
.
Note the documentation for __builtin_assoc_barrier in GCC 13/14 didn't mention
this about the builtin but the implementation inside GCC was doing it.
We do document the default of -ffp-contract too:
https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html#index-ffp-contract