Why I get a “type-punned” warning even when using a `char *`?
问题 gcc (6.3.1 20170109) when compiling the following program #include <stdio.h> int main(int argc, const char *argv[]) { unsigned char x[] = {0x66, 0x19}; printf("%i\n", ((short *)((char *)&x[0]))[0]); return 0; } generates as warning: pun.c: In function ‘main’: pun.c:5:5: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] Shouldn't type aliasing allowed when using char pointers? 回答1: Here’s what C11 (or at least the free draft N1570) has to say about