http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56421
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> 2013-02-22 10:42:05 UTC --- Isn't G++ correct? Foo::type exists unconditionally, so SFINAE doesn't apply. The invalid type is not in the immediate context of the substitution. To make this work you would have to only define Foo::type if S::type exists.