This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/80961] New: Constructor preferred over conversion operator, when should be ambiguous
- 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: Fri, 02 Jun 2017 15:21:52 +0000
- Subject: [Bug c++/80961] New: Constructor preferred over conversion operator, when should be ambiguous
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80961
Bug ID: 80961
Summary: Constructor preferred over conversion operator, when
should be ambiguous
Product: gcc
Version: 7.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: barry.revzin at gmail dot com
Target Milestone: ---
In the following example:
struct S;
struct T {
#ifdef BUG
T(S const& );
#else
T(S& );
#endif
};
struct S {
#ifdef BUG
operator T() const;
#else
operator T();
#endif
};
int main() {
S s;
T t = s;
}
Without BUG defined, the code correctly fails to compile due to the conversion
from S to T being ambiguous. With BUG defined, the conversion should still be
ambiguous for the same reason, but compiles - choosing T(S const&).