template void f() {
return 0; // returning value from function returning `void`
}
int main()
{
// Not instantiating or calling any f
Reading more closely, that standard passage says:
If a substitution results in an invalid type or expression, type deduction fails. An invalid type or expression is one that would be ill-formed if written using the substituted arguments. [..]
return 0
is not an expression, so SFINAE does not apply.
The passage goes on:
Only invalid types and expressions in the immediate context of the function type and its template parameter types can result in a deduction failure.
return 0
has nothing to do with the function type or its template parameter types, so SFINAE still does not apply.