>>>>> "Jan" == Jan Hudec <bulb@ucw.cz> writes: Jan> On Tue, Jul 13, 2004 at 17:17:41 +0530, amith wrote: >> hi all, >> >> main() >> { >> void **blkPtr; >> char *Buffer; >> char *ptr; >> Buffer = (char *) malloc(10000); >> >> if( ((unsigned long)Buffer % 4) == 0) >> printf(" Buffer = %u is divisible by 4 \n",Buffer); >> >> // Buffer++; /* if this line is commented ,the code works as >> expected */ >> blkPtr = (void **)Buffer; >> >> >> *blkPtr = ((void *)0x11223344); >> ptr = Buffer; >> printf(" value = %X address = %X\n",*ptr,ptr); >> ptr++; >> printf(" value = %X address = %X\n",*ptr,ptr); >> ptr++; >> printf(" value = %X address = %X\n",*ptr,ptr); >> ptr++; >> printf(" value = %X address = %X\n",*ptr,ptr); >> } >> [...] >> could someone bail me out of this ? Jan> I fear that the code is invalid. It violates the aliasing rules. The Jan> compiler is allowed to expect, that a char * never ever points to the Jan> same location as void **. No. -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/