> On Mar 21, 2023, at 3:51 PM, Jeff Law <jeffreya...@gmail.com> wrote:
> 
> 
> 
> On 3/21/23 13:01, Qing Zhao wrote:
> 
>> The code previously worked now has some issue since we added some new stuff 
>> into standard, and the compiler added some new transformation based on this 
>> new stuff. Should the compiler issue some warnings to warn the users about 
>> such change? Then the user will go to the new standard to get more info?
> It is not at all uncommon to have old code no longer work due to a compiler 
> update.
> 
> This can happen if the compiler changes the default version of the language 
> it's supporting (say c99 to c11) or fixes a missed-error bug (more common in 
> C++) or the optimizers just get smarter and code which was always buggy, but 
> worked by accident no longer works.
> 
> When we can reasonably give diagnostics, we try to.  Improvements in this 
> space are appreciated :-)

For this specific case,  the C standard (C99 and later) explicitly mentioned 
that the fp-contract might “undermine predictability”, “can even decrease 
accuracy” at the same time to allow it.

http://port70.net/%7Ensz/c/c99/n1256.html#note78

78) This license is specifically intended to allow implementations to exploit 
fast machine instructions that combine multiple C operators. As contractions 
potentially undermine predictability, and can even decrease accuracy for 
containing expressions, their use needs to be well-defined and clearly 
documented.

In GCC, the fp-contract is on by default, but the documentation of it doesn’t 
mention such warning at all. I think it will be helpful to add explicit warning 
in the -ffp-contract documentation. 

If you agree on this, I can come up with a patch to add such warning for 
-ffp-contract.

Qing

> 
> Jeff
> 

Reply via email to