This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/70500] New: Template deduction should fail on narrowing conversion


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() {}
```

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]