http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49399
--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-06-14 12:11:05 UTC --- The program should not compile. In C++03 it should fail to compile because it accesses a private member. SFINAE does not take access control into account in C++03, so that is an error. G++ fails to reject the program because access checking in templates is buggy. There was a last minute change in the C++0x FDIS to make SFINAE consider access control. The previous draft (http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3242.pdf) says in section 14.8.2 [temp.deduct] p8 "Access checking is not done as part of the substitution process. Consequently, when deduction succeeds, an access error could still result when the function is instantiated." That was changed in the FDIS, so accessing the private member should cause deduction to fail, so there is no broken_fun and the call to it in main should fail. G++ 4.7 doesn't implement that change yet, so rejects the program for the wrong reason. If you had a second, less specific, overload of broken_fun then the program would still be invalid in C++03 but should be well-formed in C++0x. G++ doesn't accept it because access checking is not done as part of the substitution process yet. e.g. this is valid C++0x struct broken { private: typedef int value_type; }; template <typename T> int broken_fun(int, typename T::value_type* = 0); template <typename T> char broken_fun(...); int main(int argc, char* argv[]) { return sizeof(broken_fun<broken>(5)); }