This is the mail archive of the gcc-bugs@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]
Other format: [Raw text]

[Bug c++/29437] [decl.init.ref]/5 wrongly implemented



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

Hi,

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
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1905.pdf

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


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29437


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