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

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

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

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Slightly reduced:

template <typename T>
struct __int_traits {
  static constexpr int __digits = sizeof (T) * 8;
  static constexpr T __max = ~(T) 0;
};
namespace std __attribute__ ((__visibility__ ("default")))
{
  template<typename _Tp>
    constexpr int
    __countl_zero(_Tp __x) noexcept
    {
      constexpr auto _Nd = __int_traits<_Tp>::__digits;
      if (__x == 0)
        return _Nd;
      constexpr auto _Nd_ull = __int_traits<unsigned long long>::__digits;
      constexpr auto _Nd_ul = __int_traits<unsigned long>::__digits;
      constexpr auto _Nd_u = __int_traits<unsigned>::__digits;
      if constexpr (_Nd <= _Nd_u)
        {
          constexpr int __diff = _Nd_u - _Nd;
          return __builtin_clz(__x) - __diff;
        }
      else if constexpr (_Nd <= _Nd_ul)
        {
          constexpr int __diff = _Nd_ul - _Nd;
          return __builtin_clzl(__x) - __diff;
        }
      else if constexpr (_Nd <= _Nd_ull)
        {
          constexpr int __diff = _Nd_ull - _Nd;
          return __builtin_clzll(__x) - __diff;
        }
      else
        {
          static_assert(_Nd <= (2 * _Nd_ull),
                        "Maximum supported integer size is 128-bit");
          unsigned long long __high = __x >> _Nd_ull;
          if (__high != 0)
            {
              constexpr int __diff = (2 * _Nd_ull) - _Nd;
              return __builtin_clzll(__high) - __diff;
            }
          constexpr auto __max_ull = __int_traits<unsigned long long>::__max;
          unsigned long long __low = __x & __max_ull;
          return (_Nd - _Nd_ull) + __builtin_clzll(__low);
        }
    }
  template<typename _Tp>
    constexpr _Tp
    __bit_ceil(_Tp __x) noexcept
    {
      constexpr auto _Nd = __int_traits<_Tp>::__digits;
      if (__x == 0 || __x == 1)
        return 1;
      auto __shift_exponent = _Nd - std::__countl_zero((_Tp)(__x - 1u));
      if (!__builtin_is_constant_evaluated())
        {
          ;
        }
      return (_Tp)1u << __shift_exponent;
    }
}
template<typename T>
struct Data {
    T m_a;
    T m_b;
    T m_c;
};
template<typename T>
struct alignas(std::__bit_ceil(sizeof(Data<T>))) AlignedData {
    Data<T> m_data;
};
AlignedData<int> g_test;

Seems it is the if (!__builtin_is_constant_evaluated()) { ; }
part.

Reply via email to