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]

Another strict-alias puzzle with (unsigned) char ptrs


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?
/ Adam



#include <stdio.h>


static void decode_ptr(const unsigned char **src)
{
    (*src)++;
}

int main(int argc, char **argv)
{
    const char *src0 = "";
    const char *src = src0;

    decode_ptr(&src);
    printf("sz = %lld\n", (long long)(src - src0));
}


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