http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53788
Bug #: 53788 Summary: C++11 decltype sfinae static member function check (4.7.1) Classification: Unclassified Product: gcc Version: 4.7.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: ex...@live.com Greetings all. The following code should *not* compile (one of the ways for detecting the presence or not of a static member function), because of a typo I did in T/X substitution in the check function template: Here is the testcase: /* BEGIN TESTCASE */ #include <cstdio> #include <type_traits> template<typename T> struct has_static { // NOTICE THE T/X substitution error, T::fun() should have been X::fun() // thanks to dgregor in http://llvm.org/bugs/show_bug.cgi?id=13223 template<typename X> static std::true_type check(X*, decltype(T::fun())* = 0); static std::false_type check(...); typedef decltype(check((T*)(0))) _tmp; static const bool value = _tmp::value; }; struct test { int fun() { return 0; } }; int main() { printf("%d\n", has_static<test>::value); return(0); } /* END TESTCASE */ used: g++ (GCC) 4.7.1 with --std=c++0x According to dgregor's reply in the aforementioned llvm bugzilla entry, clang is right to not compile this while g++ tacitly accepts it before its time (from 4.5.1 to 4.7.1 at least). Is this something requiring fixing? thanks.