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

--- Comment #9 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Though, on
// PR c++/108099
// { dg-do compile { target c++11 } }
// { dg-options "" }

using u128 = unsigned __int128_t;
using s128 = signed __int128_t;
template <typename T, T v> struct integral_constant {
  static constexpr T value = v;
};
typedef integral_constant <bool, false> false_type;
typedef integral_constant <bool, true> true_type;
template <class T, class U>
struct is_same : false_type {};
template <class T>
struct is_same <T, T> : true_type {};
static_assert (is_same <__int128, s128>::value, "");
static_assert (is_same <signed __int128, s128>::value, "");
static_assert (is_same <__int128_t, s128>::value, "");
static_assert (is_same <unsigned __int128, u128>::value, "");
static_assert (is_same <__uint128_t, u128>::value, "");
static_assert (sizeof (s128) == sizeof (__int128), "");
static_assert (sizeof (u128) == sizeof (unsigned __int128), "");
static_assert (s128(-1) < 0, "");
static_assert (u128(-1) > 0, "");

in GCC 11 2 assertions failed (is_same with u128), while in trunk with the
above patch 3 assertions fail (also the
sizeof (u128) - u128 is then unsigned int rather than unsigned __int128.
No idea what we want for the is_same assertions, but I bet if we just pedwarn
on unsigned __int128_t and don't reject it, users would expect at least some
128-bit unsigned type.

Though, even on:
// PR c++/108099
// { dg-do compile { target c++11 } }
// { dg-options "" }

typedef long long t64;
using u64 = unsigned t64;
using s64 = signed t64;
template <typename T, T v> struct integral_constant {
  static constexpr T value = v;
};
typedef integral_constant <bool, false> false_type;
typedef integral_constant <bool, true> true_type;
template <class T, class U>
struct is_same : false_type {};
template <class T>
struct is_same <T, T> : true_type {};
static_assert (is_same <long long, s64>::value, "");
static_assert (is_same <signed long long, s64>::value, "");
static_assert (is_same <unsigned long long, u64>::value, "");
static_assert (sizeof (s64) == sizeof (long long), "");
static_assert (sizeof (u64) == sizeof (unsigned long long), "");
static_assert (s64(-1) < 0, "");
static_assert (u64(-1) > 0, "");

in GCC 11 only one assertion failed (is_same for u64), while in GCC 12 and
unpatched or patched trunk
2 of them fail (also the sizeof (u64) one).
So, it seems the r12-8173 change behavior not just for the builtin types, but
also for any other typedefs
(in the unsigned case).

Reply via email to