mardi 24 mai 2016

Why does this static_assert only fail with clang on OS X and nowhere else?

The following code:

#include <cstdint>
#include <type_traits>

enum class Enum : std::uint64_t {
    zero,
};

static_assert(std::is_same<std::make_unsigned<Enum>::type, std::uint64_t>::value, "");

fails to compile on OS X with clang:

$ clang++ -std=c++11 -c t.cpp
t.cpp:8:1: error: static_assert failed ""
static_assert(std::is_same<std::make_unsigned<Enum>::type, std::uint64_t>::value, "");
^             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated

However, this same file works okay with clang 3.8/3.7.1/3.7/3.6/3.5.1/3.5/3.4.1/3.3 on gcc.godbolt.org.

On my system, clang is just the normal version from Xcode 7.3.1:

$ clang++ --version
Apple LLVM version 7.3.0 (clang-703.0.31)
Target: x86_64-apple-darwin15.4.0
Thread model: posix
InstalledDir: /Applications/http://ift.tt/1z8WHIF

What gives? This clearly seems to be a bug in clang on my system, but it's not clear to me why this would fail with clang from Xcode but not any of the other versions of clang. Is Xcode's clang distribution significantly different?

Aucun commentaire:

Enregistrer un commentaire