This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Binding a temporary to a const reference
- To: Joe Buck <jbuck at synopsys dot COM>
- Subject: Re: Binding a temporary to a const reference
- From: Alexandre Oliva <oliva at lsd dot ic dot unicamp dot br>
- Date: 15 Nov 1999 23:19:38 -0200
- Cc: brane at cthulhu dot engr dot sgi dot com (Branko Cibej), gcc at gcc dot gnu dot org
- References: <199911152351.PAA17681@atrus.synopsys.com>
On Nov 15, 1999, Joe Buck <jbuck@synopsys.COM> wrote:
>> A const& a = A(); // Error?
> This doesn't seem to represent a use of the copy constructor, so if
> I understand things correctly, g++ should accept it.
[dcl.init.ref]/8 says that, if the initializer expression is an rvalue
and the reference is of class type, an implementation is allowed (but
not required) to copy-construct another temporary and bind the
refenrence to it. In any case, the copy constructor must be
accessible [dcl.init.ref]/9. So g++ is right.
--
Alexandre Oliva http://www.ic.unicamp.br/~oliva IC-Unicamp, Bra[sz]il
oliva@{lsd.ic.unicamp.br,guarana.{org,com}} aoliva@{acm,computer}.org
oliva@{gnu.org,kaffe.org,{egcs,sourceware}.cygnus.com,samba.org}
** I may forward mail about projects to mailing lists; please use them