From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2117 invoked by alias); 14 Dec 2011 19:21:43 -0000 Received: (qmail 2109 invoked by uid 22791); 14 Dec 2011 19:21:42 -0000 X-SWARE-Spam-Status: No, hits=-2.9 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 14 Dec 2011 19:21:29 +0000 From: "dave at boostpro dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/51553] New: brace initialization and conversion operators Date: Wed, 14 Dec 2011 20:07: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-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: dave at boostpro 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-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 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 X-SW-Source: 2011-12/txt/msg01530.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51553 Bug #: 51553 Summary: brace initialization and conversion operators Classification: Unclassified Product: gcc Version: 4.7.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned@gcc.gnu.org ReportedBy: dave@boostpro.com Please consider this test case: --------- -------- struct X { X(); }; struct Y { operator X() const; }; struct Z { explicit operator X() const; }; X a = { Y() }; // #1. error: could not convert '{Y()}' from '' to 'X' X aa = Y(); // #1a. OK X b{ Y() }; // #2. error: no matching function for call to 'X::X()' X bb(Y()); // #2a. OK X c = { Z() }; // #3 error: could not convert '{Z()}' from '' to 'X' X cc = Z(); // #3a. error: conversion from 'Z' to non-scalar type 'X' requested X d{ Z() }; // #4 error: no matching function for call to 'X::X()' X dd( Z() ); // OK --------- -------- I can't find anything in the standard that justifies a difference between the brace- and braceless-initialization cases. Even in case #3, the difference in error message leads me to think the code may be failing for the wrong reasons.