[Bug c++/89874] New: invalid conversion accepted in decltype in a template

msebor at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu Mar 28 20:41:00 GMT 2019


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89874

            Bug ID: 89874
           Summary: invalid conversion accepted in decltype in a template
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: msebor at gcc dot gnu.org
  Target Milestone: ---

G++ accepts the following ill-formed program:

$ cat u.C && /gcc -S -Wall -Wextra u.C
char f (int);

template <typename T>
decltype (f ("123"))   // invalid: no conversion from const char* to int
g (T);

void h () { g (0); }

Clang prints:

u.C:4:11: error: no matching function for call to 'f'
decltype (f ("123"))   // invalid: no conversion from const char* to int
          ^
u.C:1:6: note: candidate function not viable: no known conversion from
      'const char [4]' to 'int' for 1st argument
char f (int);
     ^
u.C:7:13: error: no matching function for call to 'g'
void h () { g (0); }
            ^
2 errors generated.


More information about the Gcc-bugs mailing list