Issue 172651
Summary [clang] [x86_64] __builtin_isinf_sign raises FE_INVALID for denormal numbers
Labels clang
Assignees
Reporter zatrazz
    On x86_64/Linux:

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

typedef union
{
  long double value;
 struct
  {
    uint32_t lsw;
    uint32_t msw;
    int sign_exponent:16;
    unsigned int empty1:16;
    unsigned int empty0:32;
 } parts;
} ieee_long_double_shape_type;

static const ieee_long_double_shape_type pseudo_zero = { .parts = { 0x00000000, 0x00000000, 0x0100 } };

int main (int argc, char *argv[])
{
 feenableexcept (FE_INVALID);
  return __builtin_isinf_sign (pseudo_zero.value);
}
$ clang -target x86_64-linux-gnu t.c -o t -D_GNU_SOURCE -lm
$ ./t
Floating point exception
```
The glibc math.h adds a isinf optimization to use the __builtin_isinf_sign, but it is disabled when -fsignaling-nan is used (GCC [bug 66462](https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66462)). It is always enabled on clang/x86_64 because it does define __SUPPORT_SNAN__.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to