https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86259
--- Comment #3 from Vladimir Panteleev <gcc at thecybershadow dot net> --- (In reply to Andrew Pinski from comment #1) > This code is undefined. What's the problem? Might be just a bad reduction. Original code is Xorg: https://cgit.freedesktop.org/xorg/xserver/tree/xkb/XKBGAlloc.c#n818 https://cgit.freedesktop.org/xorg/xserver/tree/xkb/xkb.c#n5140 > Try -fno-strict-aliasing . No effect. (In reply to Andrew Pinski from comment #2) > Note gcc thinks strlen(s) is less than or equal to 3 as s is really T.s > which is an array of 4 in size and there for the last element has to be a > null char. (In reply to Andrew Pinski from comment #2) > Note gcc thinks strlen(s) is less than or equal to 3 as s is really T.s > which is an array of 4 in size and there for the last element has to be a > null char. The original code looks closer to this: typedef struct { unsigned char s[4]; unsigned char t[4]; } T; void fun2(char* s) { T *t = (T *) s; fun1((char*)t->s); } > there for the last element has to be a null char Why is that? Is that specific to "char"? Is there a signed 8-bit type without that property, then? I can try to re-reduce, but I'm not sure what the restrictions are.