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

            Bug ID: 91559
           Summary: math/x2y2m1q.c assumes FE_TONEAREST defined
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libquadmath
          Assignee: unassigned at gcc dot gnu.org
          Reporter: joel at gcc dot gnu.org
  Target Milestone: ---

newlib has been updated to always provide an fenv.h with prototypes for the
required methods. Unfortunately, this has triggered code in math/x2y2m1q.c
which incorrectly assumes FE_TONEAREST is always defined. Per POSIX, the
rounding mode and exception mode constants only need to be supported if they
are defined. A check for existence of fenv.h is an insufficient check.

http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/fenv.h.html

../../../../gnu-mirror-gcc-0f81292cb0a/libquadmath/math/x2y2m1q.c:57:26: 
error: 'FE_TONEAREST' undeclared (first use in this function)
    57 |   SET_RESTORE_ROUNDF128 (FE_TONEAREST);
       |                          ^~~~~~~~~~~~

This showed up on x86_64 but is likely to show up on all newlib targets which
do not have the target specific fenv support. 

The solution is just to wrap all calls using fenv.h constants with an #ifdef on
the constant used as POSIX indicates.

Reply via email to