------- Comment #81 from rguenth at gcc dot gnu dot org 2007-05-18 09:45 ------- Yes, both testcases are valid and are using placement new. Note the loop is only to confuse the optimizers enough to re-order the stores and produce a miscompilation. Note the loop runs exactly once, and in essence we are doing
int *p = XXX; /* integer memory */ *p = 0; long *q = new (p) long; *q = -1; and the compiler is re-ordering the stores which is wrong. *p and *q need to alias because of the placement new. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29286