This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/81789] New: CWG1687 performed too soon
- From: "barry.revzin at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 10 Aug 2017 00:59:45 +0000
- Subject: [Bug c++/81789] New: CWG1687 performed too soon
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81789
Bug ID: 81789
Summary: CWG1687 performed too soon
Product: gcc
Version: 7.0.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: barry.revzin at gmail dot com
Target Milestone: ---
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).