Georg-Johann Lay writes: > extern char *grub_scratch_mem; > int testload_func (char *arg, int flags) > { > int i; > for (i = 0; i < 0x10ac0; i++) > if (*((unsigned char *) ((0x200000 + i + (int) grub_scratch_mem))) > != *((unsigned char *) ((0x300000 + i + (int) grub_scratch_mem)))) > return 0; > return 1; > } > > And compiled with the command line > >> avr-gcc pr30338.c -S -Os -dp -mmcu=atmega128 -fdump-tree-original > > pr30338.c: In function 'testload_func': > pr30338.c:9:11: warning: cast to pointer from integer of different > size [-Wint-to-pointer-cast] > pr30338.c:10:14: warning: cast to pointer from integer of different > size [-Wint-to-pointer-cast] > > Frist of all, the warning is incorrect because Pmode=HImode=int on AVR.
The constant 0x200000 does not fit in a 16-bit integer. Therefore the compiler gives it the type long, as the C standard requires. The arithmetic promotion rules then cause the compiler to cast i and grub_scratch_mem to long, and to do the operation in long. The warning then occurs when casting from long to a pointer type. Ian