[Bug c++/11915] Aliasing problems with user-defined operator new

giovannibajo at libero dot it gcc-bugzilla@gcc.gnu.org
Fri Apr 2 14:22:00 GMT 2004


------- Additional Comments From giovannibajo at libero dot it  2004-04-02 14:22 -------
Confirmed again to be invalid. What happens here is that the underlying char[] 
is accessed first through a A* (within operator new) and later through a B* (in 
B's constructor). This is equivalent to:

float foo(void)
{
  char buf[64];
  int* p1 = (int*)buf;
  float* p2 = (float*)buf;
  *p1 = 123;
  return *p2;
}

This code breaks aliasing rules (confirmed by Segher Boessenkool and Paul 
Brook), so the whole PR is invalid.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11915



More information about the Gcc-bugs mailing list