Another strict-alias puzzle with (unsigned) char ptrs

Ian Lance Taylor iant@google.com
Wed Sep 27 00:53:00 GMT 2006


Adam Dickmeiss <adam@indexdata.dk> writes:

> The program below prints 1 or 0 depending on GCC version and
> -O2/-fstrict-aliasing being present or not. With proper optimizations
> enabled, 0 is printed. Otherwise, 1 is printed.
> 
> So just to understand: strict aliases also take effect for
> signed/unsigned char pointers?

Aliasing does not apply to char pointers.  That is, a pointer of type
char* is permitted to alias any other pointer, and likewise for
unsigned char* and signed char*.

> static void decode_ptr(const unsigned char **src)

But you aren't using a char* pointer, you are using a char** pointer.
And aliasing certainly does apply to char** pointers.

Ian



More information about the Gcc-help mailing list