result of fabs or fma when <math.h> is not included?
Mason
slash.tmp@free.fr
Mon May 15 13:25:00 GMT 2017
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.
More information about the Gcc-help
mailing list