This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Temporaries
- To: jbuck at racerx dot synopsys dot com
- Subject: Re: Temporaries
- From: "Martin v. Loewis" <martin at loewis dot home dot cs dot tu-berlin dot de>
- Date: Sun, 28 May 2000 16:59:06 +0200
- CC: linguist-gcc at rich-paul dot net, gcc at gcc dot gnu dot org
- References: <200005280343.UAA08821@racerx.synopsys.com>
> > Under visual c++, this is fine,
[...]
> > but under gcc it is an error (not a warning), because the
> > non-const reference parameter of operator |= is being initialized
> > with an rvalue of type 'String'.
> >
> > I always thought that an explicit constructor invocation yielded
> > an lvalue.
> No, it produces a temporary.
I'd like to point out that this is one of the more prominent bugs in
Visual C++ 5 and 6: It allows binding of temporaries to non-const
references. People therefore frequently takes this as a feature of
C++, when it is a bug in their compiler. Unfortunately, many other C++
compilers show the same bug - I believe earlier g++ versions did as
well.
Regards,
Martin