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

pinskia at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Mon Aug 18 22:48:00 GMT 2003


PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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


pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |DUPLICATE


------- Additional Comments From pinskia at gcc dot gnu dot org  2003-08-18 22:48 -------
This looks like an almost exact dup of bug 11973.
>From that bug:
Your code is invalid. What you do is this: 
- in new a->X_alc() you call C::operator new, which returns a C* which you later access 
- however, C::operator new calls alc(), which returns the memory location of an object 
  which the compiler assumes is of type SList 
Such type games violate C++'s type aliasing rules. The solution is either to fix your 
code, or if you want to play hide-and-seek with the compiler, use -fno-strict-aliasing. 

The names of the functions are different but the game is the same.

*** This bug has been marked as a duplicate of 11973 ***



More information about the Gcc-bugs mailing list