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: Another strict-alias puzzle with (unsigned) char ptrs


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


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