This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Binding a temporary to a const reference


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]