www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22878] New: importC: glibc fallback for HUGE_VAL gives "not


          Issue ID: 22878
           Summary: importC: glibc fallback for HUGE_VAL gives "not
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: duser neet.fi

// Error: number `1e10000` is not representable
double n = 1e10000;

glibc's math.h defines HUGE_VAL as 1e10000 for old or non-gnu compilers that
can't use the builtin:

/* Value returned on overflow.  With IEEE 754 floating point, this is
   +Infinity, otherwise the largest representable positive value.  *
#if __GNUC_PREREQ (3, 3)

/* This may provoke compiler warnings, and may not be rounded to
   +Infinity in all IEEE 754 rounding modes, but is the best that can
   be done in ISO C while remaining a constant expression.  10,000 is
   greater than the maximum (decimal) exponent for all supported
   floating-point formats and widths.  *


if using gcc to preprocess, you can get the fallback by undefining the gnu
version macros: -U__GNUC__ -U__GNUC_MINOR__ -U__GNUC_PATCHLEVEL__

Mar 11 2022