This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/70500] New: Template deduction should fail on narrowing conversion
- From: "akrzemi1 at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 01 Apr 2016 14:17:35 +0000
- Subject: [Bug c++/70500] New: Template deduction should fail on narrowing conversion
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70500
Bug ID: 70500
Summary: Template deduction should fail on narrowing conversion
Product: gcc
Version: 6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: akrzemi1 at gmail dot com
Target Milestone: ---
An example in the Standard shows that template deduction should fail upon
narrowing conversion from template argument. [temp.deduct] para 9:
```
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
```
However, GCC sees both calls as ambiguous. This happens on all GCC versions.
For similar reason, the following program is ill-formed (and is reported as
such by Clang), but in GCC it compiles fine:
```
template <signed char> int f(int) { return 0; }
int i = f<10000>(0);
int main() {}
```