Bug 81789 - CWG1687 performed too soon
Summary: CWG1687 performed too soon
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 7.0.1
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: accepts-invalid
Depends on:
Blocks:
 
Reported: 2017-08-10 00:59 UTC by Barry Revzin
Modified: 2022-01-25 03:17 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2021-08-27 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Barry Revzin 2017-08-10 00:59:45 UTC
Consider this reduced example taken from StackOverflow (https://stackoverflow.com/questions/45602368/correct-behavior-of-built-in-operator-candidates-of-the-overload-resolution-in-t):

struct X { X(int*); };
struct Y { operator double(); };
int operator+(X, int);

int main() {
  int{(int*)0 + Y()};
}

gcc compiles it fine. But the built-in operator, operator+(int*, std::ptrdiff_t ) should be a better match and selected by overload resolution and THEN, as a result of CWG 1687, the expression should be considered ill-formed. However, it appears that gcc pre-rejects that overload first and instead picks the provided operator+(). 

clang does the opposite, preferring the builtin operator and then not rejecting it, so this program fails to compile, but for the wrong reason (due to not being able to convert int* to int).
Comment 1 Martin Sebor 2018-02-16 02:49:07 UTC
Confirmed.  This was never rejected, so it's not a regression.  Looks like the issue resolution is not implemented yet.