https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123161

            Bug ID: 123161
           Summary: x86_64: __builtin_fpclassify raises FE_INVALID for
                    __builtin_fpclassify
           Product: gcc
           Version: 13.4.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: adhemerval.zanella at linaro dot org
  Target Milestone: ---

On x86_64:

$ 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_fpclassify (FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL,
FP_ZERO,  pseudo_zero.value);
}
$ gcc-13 t.c -o t -D_GNU_SOURCE -lm
$ ./t
Floating point exception
$ gcc-15 t.c -o t -D_GNU_SOURCE -lm
$ ./t
Floating point exception

The glibc math.h adds a fpclassify optimization to use the
__builtin_fpclassify, but it disabled when -fsignaling-nan is used (GCC bug
66462) and the glibc fpclassify tests always use the -fsignaling-nan (and
that's it has not cause a regression on glibc).

Reply via email to