Skip to content

Instantly share code, notes, and snippets.

@akinomyoga
Last active March 2, 2017 14:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akinomyoga/a42db5483a08d1b58165cc242da250a5 to your computer and use it in GitHub Desktop.
Save akinomyoga/a42db5483a08d1b58165cc242da250a5 to your computer and use it in GitHub Desktop.
msc17 (VIsual Studio 2012 cl.exe) の信じがたいバグ: std::remove_pointer<void (*)()>::type の結果が変化する
#include <cstdio>
#include <type_traits>
struct C {
C() {}
template<typename F> explicit C(const F& f, typename std::remove_pointer<F>::type* = nullptr) {}
template<typename F> void operator=(const F&) {}
};
void f() { return 0; }
template<typename> void check_type() { std::printf("%s\n", __FUNCSIG__); }
int main() {
check_type<std::remove_pointer<void (*)()>::type>(); // → void __cdecl check_type<void(void)>(void)
C g;
g = f;
check_type<std::remove_pointer<void (*)()>::type>(); // → void __cdecl check_type<void(__cdecl *)(void)>(void)
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment