>From this thread:
http://gcc.gnu.org/ml/gcc-patches/2009-02/msg00271.html
Compiling with -c -g -O2 -Wall from r143978, I only get one warning, but should
get two.
struct A
{
int j;
int i;
};
void foo()
{
char buf[sizeof(struct A)];
// warns
((struct A*)buf)->i = 1;
// does not warn
struct A* p = (struct A*) buf;
p->i = 4;
}
Gives:
alias2.c: In function void foo():
alias2.c:12: warning: dereferencing type-punned pointer will break
strict-aliasing rules
--
Summary: missed strict-aliasing warning
Product: gcc
Version: 4.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: bkoz at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39117