Why does gcc4 dislike this code?

jlh jlh@gmx.ch
Thu Jun 19 01:05:00 GMT 2008


Hi!

>> walt wrote:
>>>    *((unsigned long int *) tmp)++ = *((unsigned long int *) b1)++;
> 
> If you had to fix that code, how would you do it?

Maybe like in the following snippet?  It's ugly though.  Maybe you
need to rethink the whole thing and avoid such ugly hacks
altogether.

    unsigned long int *tmp_cast = (unsigned long int *)tmp;
    unsigned long int *b1_cast = (unsigned long int *)b1;
    *tmp_cast++ = *b1_cast++;
    tmp = (whatever_type1 *)tmp_cast;
    b1 = (whatever_type2 *)b1_cast;

jlh



More information about the Gcc-help mailing list