This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [C++ dayly bug report] const_cast to rvalue of class type
- To: Gabriel Dos_Reis <Gabriel dot Dos_Reis at sophia dot inria dot fr>
- Subject: Re: [C++ dayly bug report] const_cast to rvalue of class type
- From: Benjamin Scherrey <scherrey at switchco dot com>
- Date: Thu, 29 Apr 1999 23:10:46 -0500
- CC: egcs-bugs at egcs dot cygnus dot com, egcs at egcs dot cygnus dot com, Guillaume Laurent <glaurent at worldnet dot fr>
- Organization: Proteus Technologies, Inc.
- References: <xajyajbkl30.fsf@korrigan.inria.fr> <37291A17.754FEA25@switchco.com> <xajpv4mltfn.fsf@korrigan.inria.fr>
- Reply-To: scherrey at proteus-tech dot com
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.