Re: Offset a void pointer

Antoine Chavasse <[email protected]> Thu, 14 Oct 2004 17:28:54 +0200
Newsgroups gmane.games.devel.general
Message-ID <[email protected]>
On Thu, 14 Oct 2004 15:11:04 +0100, Richard Fabian <[email protected]> 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)


-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
_______________________________________________
Gamedevlists-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gamedevlists-general
Archives:
http://sourceforge.net/mailarchive/forum.php?forum_id=557