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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
If you are complaining about:
struct S { unsigned long long a[2]; };
struct T { unsigned long long b[6]; };
struct U { unsigned long long c[2]; long double d; unsigned long long e[2]; };

#if __SIZEOF_LONG_DOUBLE__ == 16 && __LDBL_MANT_DIG__ == 64 &&
__SIZEOF_LONG_LONG__ == 8
constexpr long double
foo (S x)
{
  return __builtin_bit_cast (long double, x);
}

constexpr S a = { 0ULL, 0xffffffffffff0000ULL };
constexpr long double b = foo (a);
static_assert (b == 0.0L, "");

constexpr U
bar (T x)
{
  return __builtin_bit_cast (U, x);
}

constexpr T c = { 0ULL, 0ULL, 0ULL, 0xffffffffffff0000ULL, 0ULL, 0ULL };
constexpr U d = bar (c);
static_assert (d.d == 0.0L, "");
#endif

which is an unintended side-effects of the PR104522 changes, then that can be
fixed e.g. with
diff --git a/gcc/fold-const.cc b/gcc/fold-const.cc
index 9aaea71a2fc..99882ef820a 100644
--- a/gcc/fold-const.cc
+++ b/gcc/fold-const.cc
@@ -8873,11 +8873,13 @@ native_interpret_expr (tree type, const unsigned char
*ptr, int len)
             valid values that GCC can't really represent accurately.
             See PR95450.  Even for other modes, e.g. x86 XFmode can have some
             bit combinationations which GCC doesn't preserve.  */
-         unsigned char buf[24];
+         unsigned char buf[24 * 2];
          scalar_float_mode mode = SCALAR_FLOAT_TYPE_MODE (type);
          int total_bytes = GET_MODE_SIZE (mode);
+         memcpy (buf + 24, ptr, total_bytes);
+         clear_type_padding_in_mask (type, buf + 24);
          if (native_encode_expr (ret, buf, total_bytes, 0) != total_bytes
-             || memcmp (ptr, buf, total_bytes) != 0)
+             || memcmp (buf + 24, buf, total_bytes) != 0)
            return NULL_TREE;
          return ret;
        }

The intent of the PR104522 change was to verify that the interpreted floating
point value represents the in memory value correctly, but padding bits
shouldn't be considered in that, they can contain anything.  That said, for IBM
double double format or e.g. x86 
extended format there are still many values which can't be interpretted
correctly,
for the latter e.g. pseudo denormals, pseudo infinities, pseudo NaNs and
unnormal values.

Reply via email to