This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/51553] New: brace initialization and conversion operators
- From: "dave at boostpro dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 14 Dec 2011 19:21:28 +0000
- Subject: [Bug c++/51553] New: brace initialization and conversion operators
- Auto-submitted: auto-generated
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:
--------- <schnipp> --------
struct X
{
X();
};
struct Y
{
operator X() const;
};
struct Z
{
explicit operator X() const;
};
X a = { Y() }; // #1. error: could not convert '{Y()}' from '<brace-enclosed
initializer list>' to 'X'
X aa = Y(); // #1a. OK
X b{ Y() }; // #2. error: no matching function for call to
'X::X(<brace-enclosed initializer list>)'
X bb(Y()); // #2a. OK
X c = { Z() }; // #3 error: could not convert '{Z()}' from '<brace-enclosed
initializer list>' 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(<brace-enclosed initializer list>)'
X dd( Z() ); // OK
--------- <schnapp> --------
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.