[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#478734: g++-4.2: refuses to compile valid C++ syntax

* Jason Kraftcheck:

> The same syntax is accepted by the only other C++ compiler I have
> access too: Sun's.  I guess what I don't understand is why, if I
> create a temporary by explicitly calling the copy constructor, that
> temporary is treated as an rvalue.

The standard says so in section 3.10 ("Lvalues and rvalues"):

| 6 An expression which holds a temporary object resulting from a cast to
|   a nonreference type is an rvalue (this includes the explicit creation
|   of an object using functional notation (5.2.3)).

The type you're casting to is not a reference type, so it's an rvalue
according to section 5.4 ("Explicit type conversion (cast notation)").

Reply to: