------- Comment #2 from rguenth at gcc dot gnu dot org 2007-07-16 08:40 ------- Note that sticking attribute realloc on realloc might just work because realloc takes the old memory pointer as argument which makes it
1) escape 2) potentially read from / written to So we only can manage to trick the compiler into mis-using the alias information it creates by making the program undefined like so: #include <stdlib.h> int foo() { int *p, *q; p = malloc (4); q = realloc (p, 4); *q = 1; *p = 0; return *q; } where the compiler happily decides to return 1. So basically, realloc acts as a barrier for stores and loads to/from the old memory at the moment and the result is assigned a new nothing-aliasing memory tag. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32771