This is the mail archive of the
mailing list for the GCC project.
[Bug c++/29437] [decl.init.ref]/5 wrongly implemented
- From: "joseph dot rajesh at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 12 Oct 2006 12:10:07 -0000
- Subject: [Bug c++/29437] [decl.init.ref]/5 wrongly implemented
- References: <firstname.lastname@example.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #4 from joseph dot rajesh at gmail dot com 2006-10-12 12:10 -------
(In reply to comment #3)
> Forget this, the type of the rhs is of course an rvalue of type Base,
> there is no need to copy the entire Derived object.
I was pointing to the same error. But I think I haven't put across it
properly... But I think in the latest version of C++ standard they are changing
this. They modified the line in the draft(not yet released though).
Please have a look at the latest C++ draft
Following is the extract from section 5.16.3 of the draft.
The process for determining whether an operand expression E1 of type T1 can be
converted to match an operand expression E2 of type T2 is defined as follows:
? If E2 is an lvalue: E1 can be converted to match E2 if E1 can be implicitly
converted (clause 4) to the type ?reference to T2?, subject to the constraint
that in the conversion the reference must bind directly (8.5.3) to E1.
? If E2 is an rvalue, or if the conversion above cannot be done:
- if E1 and E2 have class type, and the underlying class types are the same
or one is a base class of the other: E1 can be converted to match E2 if the
class of T2 is the same type as, or a base class of, the class of T1, and the
cv-qualification of T2 is the same cv-qualification as, or a greater
cv-qualification than, the cv-qualification of T1. If the conversion is
applied, E1 is changed to an rvalue of type T2 that [DELETE]still refers to the
source class object (or the appropriate subobject thereof). [ Note: that is, no
copy is made. ?end note][/DELETE] by copy-initializing a temporary of type T2
from E1 and using that temporary as the converted operand.
The [DELETE][/DELETE] section is deleted from the draft.
So if this section is there in the yet to be released standard then it says
that the copy will be made.