public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/51553] New: brace initialization and conversion operators
@ 2011-12-14 20:07 dave at boostpro dot com
  2011-12-19 16:41 ` [Bug c++/51553] " jason at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: dave at boostpro dot com @ 2011-12-14 20:07 UTC (permalink / raw)
  To: gcc-bugs

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.


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2015-10-17 14:14 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-14 20:07 [Bug c++/51553] New: brace initialization and conversion operators dave at boostpro dot com
2011-12-19 16:41 ` [Bug c++/51553] " jason at gcc dot gnu.org
2011-12-19 20:13 ` jason at gcc dot gnu.org
2011-12-19 20:17 ` jason at gcc dot gnu.org
2011-12-19 20:19 ` jason at gcc dot gnu.org
2014-06-30 23:16 ` david.d.kretzmer at gmail dot com
2014-07-01 10:00 ` redi at gcc dot gnu.org
2014-07-01 11:03 ` david.d.kretzmer at gmail dot com
2015-10-17 14:14 ` redi at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).