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: Temporaries


> > 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

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