This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/80961] New: Constructor preferred over conversion operator, when should be ambiguous


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&).

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]