Re: [GD-General] Offset a void pointer
Brought to you by:
vexxed72
From: Antoine C. <a.c...@gm...> - 2004-10-14 15:28:59
|
On Thu, 14 Oct 2004 15:11:04 +0100, Richard Fabian <ra...@gm...> wrote: > if you are referring to this: > > http://gcc.gnu.org/gcc-3.4/changes.html > from the section starting: > "The cast-as-lvalue extension has been removed for C++ and deprecated > for C and Objective-C. In particular, code like this: " > > then that is just that GCC has caught up with MS compilers in > dissallowing the implicit lvalue return of standard C style casts I don't think so. I think it's more that they're catching up with iso c++ 99 standard, as most compilers, including MS ones, do. In fact, that change happened at the same time they rewrote their c++ parser from scratch to attain better standard conformance. They refer is as "cast-to-lvalue *extension*", which imo imply that it's not part of the standard. > > Still appears to be perfectly legal to cast to an explicit lvalue type... Not if you consider that "cast-as-lvalue", as they put it, might mean "using a cast expression as if it was a lvalue". I don't see any exception being made here depending on what you're casting to. > > Please correct me if i am wrong on this... At least in my head it > certainly seems to make no sense to take out casting to a modifiable > type... I don't know, it doesn't surprise me they forbid it. It seems to me that about the only thing it could be used for is to specify the size of data pointed by a void pointer, as you shown before. What would it mean in other cases ? What would it do ? > > Regarding Ola Olsson: static_cast is a little bit safer, as the types > Cavey Gerard was referring to were reasonably compatible. AFAIK > reinterpret_cast is used to allow you to do more "dodgy" casting, e.g. > between a function pointer and a float, something which static_cast > does not do... reinterpret_cast is indeed the most permissive C++ cast, but iirc it's usage is not guaranteed to be portable (for reasons like endianess) |