[Bug c/103123] incorrect or misleading warning "floating constant exceeds range of ..." in ISO C11 and C17

pinskia at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Nov 8 03:12:26 GMT 2021


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

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
The code in GCC:
  /* Both C and C++ require a diagnostic for a floating constant
     outside the range of representable values of its type.  Since we
     have __builtin_inf* to produce an infinity, this is now a
     mandatory pedwarn if the target does not support infinities.  */
  if (REAL_VALUE_ISINF (real)
      || (const_type != type && REAL_VALUE_ISINF (real_trunc)))
    {
      *overflow = OT_OVERFLOW;
      if (!(flags & CPP_N_USERDEF))
        {
          if (!MODE_HAS_INFINITIES (TYPE_MODE (type)))
            pedwarn (input_location, 0,
                     "floating constant exceeds range of %qT", type);
          else
            warning (OPT_Woverflow,
                     "floating constant exceeds range of %qT", type);
        }
    }


This is warning and can be turned off, -Woverflow is on by default.


More information about the Gcc-bugs mailing list