Consider the following small test program for type traits of the GNU-extensions for __uint128_t
#include <limits>
#include <type_traits>
using uint128_t = __uint128_t;
int main()
{
static_assert(std::is_unsigned<uint128_t>{}, "");
static_assert(std::is_integral<uint128_t>{}, "");
static_assert(std::numeric_limits<uint128_t>::digits == 128, "");
}
This works for g++ and libstdc++ (working example) and for clang++ and libc++ (working example), but not for the combination clang++ and libstdc++ (failing example).
Note that in all 3 cases I use the -std=gnu++1z
flag.
Question: which combination of command-line parameters can successfully compile my test program for clang++ with libstdc++?
-std=c++1z
mode as well. From the standard's perspective, the way GCC has defined this type means it's not an integer type, just a custom type that happens to work pretty much like an integer type, and in standard-conforming mode the type traits reflect that. (I'm not sure how clang/libc++ have defined it. It's possible that it qualifies as an integer type in their implementation.) – Pantalets-std=gnu++1z
, and only in the case clang + libstdc++ did it fail – Flutterstd::numeric_limits<uint128_t>
on Apple platforms, see Apple Clang and numeric_limits<unsigned __int128>::max() is 0? – Reprobative