From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8408 invoked by alias); 7 Apr 2004 13:57:49 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 8342 invoked by alias); 7 Apr 2004 13:57:43 -0000 Date: Wed, 07 Apr 2004 13:57:00 -0000 Message-ID: <20040407135743.8336.qmail@sources.redhat.com> From: "robert dot schweikert at abaqus dot com" To: gcc-bugs@gcc.gnu.org In-Reply-To: <20040402143013.14823.robert.schweikert@abaqus.com> References: <20040402143013.14823.robert.schweikert@abaqus.com> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug c++/14823] the copy constructor is called unnecessarily/incorrectly when passing an arg by reference to the base class X-Bugzilla-Reason: CC X-SW-Source: 2004-04/txt/msg00646.txt.bz2 List-Id: ------- 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