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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 15/05/2017 13:22, Vincent Lefevre wrote:

> 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.

Isn't it UB to (re)define standard functions?

Regards.



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux