https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86908
--- Comment #9 from Jonathan Wakely ---
(In reply to Kostya Frumkin from comment #8)
> At the same time this design pattern (strategy) with placement-new is more
> efficient than with common new.
That's fine, but you can't use to access the
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86908
--- Comment #8 from Kostya Frumkin ---
> Either way you need to placement new the original type back again, otherwise
> the wrong destructor gets called on scope exit, which adds more undefined
> behaviour.
There should not be undefined
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86908
--- Comment #7 from Jonathan Wakely ---
(In reply to Richard Biener from comment #6)
> (In reply to Jonathan Wakely from comment #1)
> > No, your program has undefined behaviour. To make it valid you either need
> > to use std::launder, or use
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86908
Richard Biener changed:
What|Removed |Added
CC||rguenth at gcc dot gnu.org
--- Comment
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86908
--- Comment #5 from Kostya Frumkin ---
(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
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86908
--- Comment #4 from Jonathan Wakely ---
(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
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86908
Kostya Frumkin changed:
What|Removed |Added
Status|RESOLVED|UNCONFIRMED
Version|unknown
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86908
--- Comment #2 from Jonathan Wakely ---
This makes the program correct:
strategyPtr = new() AStrategy;
static_cast(std::launder())->doIt();
strategyPtr->doIt();
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86908
Jonathan Wakely changed:
What|Removed |Added
Status|UNCONFIRMED |RESOLVED
Resolution|---