public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jonathan Wakely <jwakely.gcc@gmail.com>
To: Michael Powell <mwpowellhtx@gmail.com>
Cc: gcc-help <gcc-help@gcc.gnu.org>
Subject: Re: Problem with braced-init-lists and explicit ctors
Date: Mon, 03 Feb 2014 07:12:00 -0000	[thread overview]
Message-ID: <CAH6eHdTnCNR0MQwxvvYFs1vq-cPdh63k9o2QWJNptJ3sNNxJ3A@mail.gmail.com> (raw)
In-Reply-To: <CAMEoF_EKztZKTnV-qw1GE46HF9c2hK63uTreuEhvdBH+y9g8Dg@mail.gmail.com>

On 2 February 2014 21:07, Michael Powell wrote:
> Hmm, so it seems MSVC isn't the only compiler with initializer list issues... ?

G++ apparently has a bug in this area, but otherwise has excellent
support for initializer lists.

> My question is, to borrow a coined phrase, how do you "reason" about
> this one? Which version of "f" would you expect to be called,

It's not possibly to implicitly create a bar object form an int,
because it's constructor is explicit. Therefore f(foo) is the only
viable overload.

> and why
> would that be practical anyway, potentially confusing foo with bar?

That's not really relevant, the compiler has to do what the language
standard says, whether the code is useful or not.

> So in other words, my question would be, is this truly a bug?

It's a bug.

Argument passing is copy-initialization ([dcl.init]/14), so f({0}) is
copy-list-initialization, and so if overload resolution chooses an
explicit constructor it's ill-formed ([over.match.list]/1)

      reply	other threads:[~2014-02-03  7:12 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-02  9:10 Joaquin M Lopez Munoz
2014-02-02  9:26 ` Marc Glisse
2014-02-02  9:38   ` Joaquin M Lopez Munoz
2014-02-02 21:07   ` Michael Powell
2014-02-03  7:12     ` Jonathan Wakely [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAH6eHdTnCNR0MQwxvvYFs1vq-cPdh63k9o2QWJNptJ3sNNxJ3A@mail.gmail.com \
    --to=jwakely.gcc@gmail.com \
    --cc=gcc-help@gcc.gnu.org \
    --cc=mwpowellhtx@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).