public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "robert dot schweikert at abaqus dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/14823] the copy constructor is called unnecessarily/incorrectly when passing an arg by reference to the base class
Date: Wed, 07 Apr 2004 13:57:00 -0000	[thread overview]
Message-ID: <20040407135743.8336.qmail@sources.redhat.com> (raw)
In-Reply-To: <20040402143013.14823.robert.schweikert@abaqus.com>


------- Additional Comments From robert dot schweikert at abaqus dot com  2004-04-07 13:57 -------
Subject: Re:  the copy constructor is called
	unnecessarily/incorrectly when passing an arg by reference to the base class

OK,

One more message on this subject. I have conferred with a few more
people and I was obviously confused. 

Sorry for taking up your time. Thanks for the clarifications you
provided and for your patience.

There is no bug, I will fix the code.

Thanks,
Robert

On Mon, 2004-04-05 at 09:49, giovannibajo at libero dot it wrote:
> ------- Additional Comments From giovannibajo at libero dot it  2004-04-05 13:49 -------
> Subject: Re:  the copy constructor is called unnecessarily/incorrectly when passing an arg by reference to the base class
> 
> robert dot schweikert at abaqus dot com wrote:
> 
> >> Where exactly does the standard speak of a rvalue-to-lvalue
> >> conversion?
> >
> > That would be on page 147 in the [dcl.init.ref] section (8.5.3) bullet
> > 5.
> >  [...]
> > "
> > - has a class type (i.e. T2 is a class type) and can be implicitly
> > converted to an lvalue ....
> > "
> >
> > So T2 in this case would be the rvalue and the reference would be
> > bound to the result of the conversion (lvalue).
> 
> It says: "**IF** the initializer expression [...] has a class type and can be
> implicitly converted to an lvalue [...] then the reference is bound directly"
> (my stress). So we have an if-then clause. A temporary created by the explicit
> function notation is a rvalue. How can it be converted to an lvalue? This is
> what I asked. You didn't show me where the standard says that a rvalue of that
> kind (or any kind) can be implicitly converted to a lvalue. There is no default
> conversion to do so. So the "if" condition is false.
> 
> > At the end of the page one can find the following note:
> > "
> > [Note the usual lvalue-to-rvalue (4.1), array-to-pointer (4.2), and
> > function-to-pointer (4.3) standard conversions are not needed, and
> > therefore are suppressed, when such direct bindings to lvalues are
> > done.]
> 
> Yes, but we're speaking of binding to *lvalues*. Your initializer expression is
> a rvalue. And there is no way it can be converted.
> 
> > Lets consider the following simple example:
> > [...] yet this simple example compiles just fine.
> 
> I don't have time to analyze it properly, but by the looks of it it shouldn't
> compile. If it does, it's a bug. Please, file a different bug report for this.
> 
> Giovanni Bajo


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14823


  parent reply	other threads:[~2004-04-07 13:57 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-04-02 14:30 [Bug c++/14823] New: " robert dot schweikert at abaqus dot com
2004-04-02 14:31 ` [Bug c++/14823] " robert dot schweikert at abaqus dot com
2004-04-02 14:47 ` pinskia at gcc dot gnu dot org
2004-04-02 15:18 ` robert dot schweikert at abaqus dot com
2004-04-02 17:41 ` bangerth at dealii dot org
2004-04-02 18:01 ` pinskia at gcc dot gnu dot org
2004-04-02 18:22 ` robert dot schweikert at abaqus dot com
2004-04-03 17:08 ` giovannibajo at libero dot it
2004-04-05 13:17 ` robert dot schweikert at abaqus dot com
2004-04-05 13:20 ` robert dot schweikert at abaqus dot com
2004-04-05 13:45 ` robert dot schweikert at abaqus dot com
2004-04-05 13:50 ` giovannibajo at libero dot it
2004-04-07 13:57 ` robert dot schweikert at abaqus dot com [this message]
2004-08-27  8:51 ` pinskia at gcc dot gnu dot org
2004-08-27  8:51 ` pinskia at gcc dot gnu dot org

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=20040407135743.8336.qmail@sources.redhat.com \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /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).