result of fabs or fma when <math.h> is not included?

Georg-Johann Lay gjl@gcc.gnu.org
Mon May 15 21:02:00 GMT 2017


Vincent Lefevre schrieb:
> Following PR80756 (which is currently about missing diagnostics, but
> the problem may be more important), what should be the result of the
> following code?
> 
> double fabs (double x)
> {
>   return x + 1.0;
> }
> 
> int main (void)
> {
>   double x = fabs (2.0);
>   return x != 3.0;
> }
> 
> Note that <math.h> is not included. When -fno-builtin-fabs is used,
> the program returns 0 (because x == 3.0). But by default, a builtin
> is used, and the program returns 1. Since <math.h> is not included,
> I don't think this is correct. But Clang has the same behavior.
> 
> Note that neither give any warning, even with -Wall -Wextra.
> 



More information about the Gcc-help mailing list