This is the mail archive of the gcc@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]

Re: [C++ dayly bug report] const_cast to rvalue of class type


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.


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