This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Why does gcc4 dislike this code?


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]