template <typename T> void f() { return 0;
In the comments on this answer, David claims that a function template that contains a semantic error and is not created leads to a bad form of the program:
Whether the template is used or not, the program is poorly formed even without an instance, but the compiler is not required to diagnose it.
And vice versa, I’m sure that SFINAE, as well as preventing type subtraction and, therefore, creating a function template in [C++11: 14.8.2/8] , allows the program to remain well formed. however, I cannot find text in this standard paragraph that explicitly speaks of this.
Who is right?
Wikipedia, which I will not consider authoritative for this issue, speaks of a slightly different case:
[..] SFINAE was introduced to avoid creating poorly formed programs when unrelated template declarations were detected [..]
(my emphasis)
source share