Typecast bug

zoltan@bendor.com.au zoltan@bendor.com.au
Wed Apr 26 22:36:00 GMT 2006


On 26 Apr 2006, Gabriel Dos Reis wrote:

> <zoltan@bendor.com.au> writes:
>
> | It is gcc 4.1.0, --target=arm-elf compiled on an Intel platform and
> | GNU/Linux.
> |
> | The following construct:
> |
> | void *p;
> |
> | 	((char *)p)++;
> |
> | makes the compiler to issue an error message, namely
> | "invalid lvalue in increment"
> |
> | The ((char *)p) construct is perfectly valid object, a char pointer which
> | can be lvalue and rvalue alike. For some reason gcc 4.1.0 (and 4.0.2 as
> | well) treats ((SOME_TYPE *)p) as if it could not be an lvalue;
>
> indeed, it is not; in any ISO C version I know of.

OK - my bad. Wrote first thought later. Old gcc accepted the construct and
legacy code broke on the new compiler. My sincere apologies.

The question, however, remains: (how) can I tell the compiler to treat a
pointer declared as void *p; as if it was a SOME_TYPE *p pointer without
introducing temporaries?

Sorry again,

Thanks,

Zoltan




More information about the Gcc-bugs mailing list