------- Comment #8 from davidxl at gcc dot gnu dot org  2010-02-03 21:44 -------
(In reply to comment #7)
> It is valid to use placement new to construct a more or less derived type
> which would change the vtable pointer.
> 
> Thus I think this bug is still invalid.
> 

How did you reach this conclusion from reading p7 of 3.8 in the standard?
"The original object was a most derived object of type T and the new object is
a most derived object of type T...."

The following is allowed:
class B {
 virtual ...
};

class D : public B {
  ...
};

B* bp = new D ();
...

new (bp) D();

but vptr does not change.


Set aside the standard -- this optimization is useful regardless. Some of the
develpoers are so desperate that they manually do LICM of vptr and vtbl access
for vcalls in the loop.  The worst case is to use a option to guard it (which I
think the default should be on).

David


-- 


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

Reply via email to