Re: [GD-General] Offset a void pointer
Brought to you by:
vexxed72
From: Antoine C. <a.c...@gm...> - 2004-10-14 17:24:14
|
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 > > 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. |