Re: Offset a void pointer
Antoine Chavasse <[email protected]> Thu, 14 Oct 2004 19:24:07 +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 > > Still appears to be perfectly legal to cast to an explicit lvalue type... > > 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... > Alright, my apologies, for I misunderstood what they meant. The comments in gcc release notes were only refering to gcc extension of cast-as-lvalue as in the additional stuff they allowed there, not as cast-as-lvalue as a whole. I tried to compile this with gcc 3.4.0: void *ptr; (char*&)ptr += 5; and indeed, it worked. Trying to compile void *ptr; (char)ptr += 5; gave the following error message: "error: ISO C++ forbids cast to non-reference type used as lvalue" Which confirm that the standard allows using cast as a reference, and only them, as lvalues, so you were right. I'll be banging my head on some nearby wall. ------------------------------------------------------- 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