Issue 172499
Summary [clang] __builtin_isgreater/__builtin_isgreaterequal/__builtin_isless/__builtin_islessequal/__builtin_islessgreater does not handle unordered comparisons
Labels clang
Assignees
Reporter zatrazz
    The following code triggers an invalid exception on ABIs that suppors 128 bit float types (either by long double or extended types like __float128):

$ cat t.c
#include <math.h>
#include <stdio.h>
#include <fenv.h>

int main (int argc, char *argtv[])
{
  feenableexcept (FE_INVALID);

  long double qNaN = __builtin_nanl ("");
  long double zero = 0;

  int r = __builtin_isgreater (zero, qNaN);
  printf ("%d\n", r);
}
$ clang -target aarch64-linux-gnu t.c -o t -D_GNU_SOURCE -lm
$ ./t
Floating point exception (core dumped)

It is not a problem for compiler-rt because it does not support floating point exceptions; but is an issue when using the gcc libgcc. This is triggered by the glibc testsuite when either using clang as the test compiler [1] or by using clang as the built compiler [2].

My plan is to disable an optimization on glibc math.h where isfunction is routed to its builtin conterpart, as least for types different than float and double.

[1] https://sourceware.org/bugzilla/show_bug.cgi?id=33322
[2] https://sourceware.org/git/?p=glibc.git;a=commit;h=be48ae12b10b0556895e356c3ae34b8ca229e61b
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to