The standard N4140 (credit goes to M.M) gives this explanation and sample in 14.8.2 Template argument deduction:
9 Except as described above, the use of an invalid value shall not cause type deduction to fail. [Example:
In the following example 1000 is converted to signed char
and results in an implementation-defined value
as specified in (4.7). In other words, both templates are considered even though 1000, when converted to
signed char, results in an implementation-defined value.
template <int> int f(int);
template <signed char> int f(int);
int i1 = f<1>(0); // ambiguous
int i2 = f<1000>(0); // ambiguous
— end example ]
However, note that in following drafts the rules are changed because:
This is no longer correct, even ignoring the fact that some implementations may be able to represent the value 1000 as a signed char
: integral and enumeration non-type template arguments are now converted constant expressions (14.3.2 [temp.arg.nontype] paragraph 1), and converted constant expressions disallow narrowing conversions (5.20 [expr.const] paragraph 3).
The proposed sample is:
template <int> int f(int);
template <signed char> int f(int);
int i1 = f<1000>(0); // OK
int i2 = f<1>(0); // ambiguous; not narrowing