Bug 89874 - invalid conversion accepted in decltype in a template
Summary: invalid conversion accepted in decltype in a template
Status: RESOLVED DUPLICATE of bug 57943
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 9.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: accepts-invalid
Depends on:
Blocks:
 
Reported: 2019-03-28 20:41 UTC by Martin Sebor
Modified: 2019-03-28 21:50 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail: 4.1.3, 4.3.5, 4.4.7, 4.8.5, 4.9.4, 5.4.0, 6.4.0, 7.3.0, 8.3.0, 9.0
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Sebor 2019-03-28 20:41:14 UTC
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.
Comment 1 Martin Sebor 2019-03-28 20:46:32 UTC
This was never rejected going as far back as GCC 4.1.

*** This bug has been marked as a duplicate of bug 57943 ***
Comment 2 Martin Sebor 2019-03-28 21:50:32 UTC
See pr47488 for the origin of the test case.