Search code examples
c++templatesvisual-studio-2015calling-conventionclang-cl

Compiler attribute stuck on a function type - is there a workaround for this clang-cl bug?


When using the C++ LLVM-vs2014 configuration in Visual Studio 2015, this static assert fails. The assert does not fail in clang++, gcc, or even Visual C++. The thiscall attribute is stuck on the function type, even though it's no longer applicable. I've filed a bug report, but I'd like to know if there's a way to forcefully remove the attribute in the meantime. Can thiscall be removed?

#include <type_traits>

template<typename T>
struct remove_member_pointer;

template<typename T, typename U>
struct remove_member_pointer<T U::*> {
    using type = T;
};

struct foo;

using input = void(foo::*)();
using expect = void();
using result = typename remove_member_pointer<input>::type;

//This static_assert fails because there is a
//compiler-generated attribute left behind, making
//the type of result actually `void () __attribute__((thiscall))`
static_assert(std::is_same<result, expect>{}, "");

int main() { return{}; }

Microsoft Visual Studio Community 2015 Version 14.0.24720.00 Update 1


Solution

  • I did not find a workaround for VS 2015 Update 1, but this issue does appear to be fixed in VS 2015 Update 2.