[Bug c++/31289] gcc412 elides code in operator delete() override method

2007-03-21 Thread jima at cadence dot com
--- Comment #8 from jima at cadence dot com 2007-03-21 20:58 --- I tried using placement-new and explicit destructor calls to delineate the lifetime of the allocator's internal class objects explicitly, such that their lifetimes do not overlap with any references to the same storage vi

[Bug c++/31289] gcc412 elides code in operator delete() override method

2007-03-21 Thread jima at cadence dot com
--- Comment #7 from jima at cadence dot com 2007-03-21 16:13 --- (In reply to comment #6) > ... the proper way is to start a new object lifetime using placement new. Are you referring only to internal operations in MyHeap::Malloc (in the demo program), or do you mean that the overall sc

[Bug c++/31289] gcc412 elides code in operator delete() override method

2007-03-21 Thread rguenth at gcc dot gnu dot org
--- Comment #6 from rguenth at gcc dot gnu dot org 2007-03-21 09:58 --- This is related to PR29286, the C++ aliasing rules are disputedly different from the C ones. So at the moment you cannot implement an allocator in C++ (and in C in general). That said, the proper way is to start a

[Bug c++/31289] gcc412 elides code in operator delete() override method

2007-03-20 Thread jima at cadence dot com
--- Comment #5 from jima at cadence dot com 2007-03-21 02:31 --- (In reply to comment #4) > (In reply to comment #3) >... Why do you think 1 or 2 more > instructions will be a hit, most of the problems you are going to hit into now > is cache issues anyways unless you do a better malloc

[Bug c++/31289] gcc412 elides code in operator delete() override method

2007-03-20 Thread pinskia at gcc dot gnu dot org
--- Comment #4 from pinskia at gcc dot gnu dot org 2007-03-21 01:40 --- (In reply to comment #3) > Can you point me to a description of the C++ aliasing rules? You can find some of it on http://gcc.gnu.org/bugs.html under the non bug section. There are a lot more pages on then I can

[Bug c++/31289] gcc412 elides code in operator delete() override method

2007-03-20 Thread jima at cadence dot com
--- Comment #3 from jima at cadence dot com 2007-03-21 01:32 --- Can you point me to a description of the C++ aliasing rules? Is the memcpy() workaround specific to GCC, or is memcpy part of the standard with special rules regarding aliasing? (I ask because our code base has to work on

[Bug c++/31289] gcc412 elides code in operator delete() override method

2007-03-20 Thread pinskia at gcc dot gnu dot org
--- Comment #2 from pinskia at gcc dot gnu dot org 2007-03-21 01:14 --- Note memcpy is the only way to be aliasing safe in this case, oh and make sure you don't cast the incomming pointer from malloc or from your free. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31289

[Bug c++/31289] gcc412 elides code in operator delete() override method

2007-03-20 Thread pinskia at gcc dot gnu dot org
--- Comment #1 from pinskia at gcc dot gnu dot org 2007-03-21 01:13 --- This is definitely a C/C++ aliasing violation as you are first accessing it as a MyHeap::Node and then as derived. Here is how I would fix it for the first one I would change it to: void * newnode = malloc(bytes_