https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86908

--- Comment #5 from Kostya Frumkin <fro0m.spam at gmail dot com> ---
(In reply to Jonathan Wakely from comment #4)
> (In reply to Kostya Frumkin from comment #3)
> > Hi, for example msvc2013 calls base class's virtual method when msvc2015
> > calls derived class's virtual method.
> 
> It's undefined behaviour. Anything can happen.
> 
> > This is developer's mistake which can be predicted by compiler. Few
> > developers know about this behavior.
> 
> Using placement new to replace a polymorphic type is not a common idiom, I
> don't think it's worth adding a warning about it. Just don't do it.
> 
> > It'd be awesome to see the correct behavior or at least warning that base
> > method is being used after placement new.
> 
> GCC's behaviour is already correct.

It is best way to get away with heap allocation in many cases. Let's make a
warning about undefined behavior.

Reply via email to