https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64418

            Bug ID: 64418
           Summary: User-defined conversion not properly suppressed in
                    certain cases of list-initialisation
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: momchil.velikov at gmail dot com

Consider the example:
--- 8< ------
struct C {
  C(const C &);
};

struct X {
  operator C() const;
};

C a{X()};

--- 8< ------

This program is successfully compiled. However, I believe this is an
erroneous behavior.

The variable "a" is initialised by direct list-initialization
according to 8.5.4. [dcl.init.list] #3 and 13.3.1.7 [over.match.list].
As the class C does not have an initializer-list ctor, all the
constructors of C are tried with the elements of the initializer list
as arguments.

GCC tries and in fact finds a user-defined conversion sequence from X
to the first parameter of the C's copy-ctor.

However, according to 13.3.3.1 [over.best.ics] #4, 

"[...] when considering the argument of a constructor [...] that is a
candidate by [...] by 13.3.1.7 [...] or when the initializer list has
exactly one element and a conversion to some class X or reference to
(possibly cv-qualified) X is considered for the first parameter of a
constructor of X [...] only standard conversion sequences and ellipsis
conversion sequences are considered.

Bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51553 is related to this one.

Reply via email to