[C++ dayly bug report] const_cast to rvalue of class type
Benjamin Scherrey
scherrey@switchco.com
Thu Apr 29 20:16:00 GMT 1999
Hmmm... 5.2.11 part 1 does not appear to disallow this cast and part 4
says that an lvalue of type T1 can be const_cast to an lvalue of type T2
as long as a pointer to T1 can be converted to a pointer to T2. That
would allow this conversion the way I read it. This lvalue rvalue stuff
always gets me screwed up but that's how I read it. Now the limitation
you're talking about is certainly true and explicitly stated for dynamic
casts. If I'm wrong I'd really like to know why.
thanx & later,
Ben Scherrey
Gabriel Dos_Reis wrote:
>
> Benjamin Scherrey <scherrey@switchco.com> writes:
>
> | Please pardon my ignorance here but I'm not sure I understand what the
> | issue is. For const_cast, the return type for a cast from anything other
> | than a reference type is an rvalue.
>
> No, you can use const_cast<T> if T is one of
> - pointer type
> - reference type
> Any other type is forbidden.
More information about the Gcc-bugs
mailing list