Why does gcc4 dislike this code?
Thu Jun 19 01:14:00 GMT 2008
On Wed, Jun 18, 2008 at 19:16, walt <firstname.lastname@example.org> wrote:
> Brian Dessent wrote:
>> walt wrote:
>>> *((unsigned long int *) tmp)++ = *((unsigned long int *) b1)++;
>>> error: invalid lvalue in increment
>> The lvalue cast was a nonstandard gcc extension that was removed in 3.4;
>> in other words this is not valid standard C/C++.
> Wow, that was fast, thanks. I'm quite sure I'd never write code
> like that in the first place, mostly because it would never occur
> to me to try it. If you had to fix that code, how would you do it?
memcpy(tmp, b1, sizeof(long));
tmp += sizeof(long);
b1 += sizeof(long);
(assuming tmp and b1 are char*)
Reading and writing through those casts are likely a violation of
More information about the Gcc-help