From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12323 invoked by alias); 27 Dec 2014 16:00:25 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 12257 invoked by uid 48); 27 Dec 2014 16:00:20 -0000 From: "momchil.velikov at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/64418] New: User-defined conversion not properly suppressed in certain cases of list-initialisation Date: Sat, 27 Dec 2014 16:00:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 5.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: momchil.velikov at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-12/txt/msg02777.txt.bz2 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.