This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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.

-- 
Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]