This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Another strict-alias puzzle with (unsigned) char ptrs
- From: Ian Lance Taylor <iant at google dot com>
- To: Adam Dickmeiss <adam at indexdata dot dk>
- Cc: gcc-help at gcc dot gnu dot org
- Date: 26 Sep 2006 17:53:28 -0700
- Subject: Re: Another strict-alias puzzle with (unsigned) char ptrs
- References: <45199574.6040907@indexdata.dk>
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