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

            Bug ID: 67703
           Summary: assert after placement new
           Product: gcc
           Version: 5.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: piotrekpad at gmail dot com
  Target Milestone: ---

Hi,
This code is is c++11 valid:

#include <memory>
#include <cassert>
struct A {
  virtual void foo();
};

struct B  : A{ 
  void foo();
};
void f() {
  A *a = new A;
  a->foo();
  A* b = new(&a) B;
  assert(a == b);
  b->foo();
  new(b) A;
  a->foo();
}

but when I compile it with g++ 5.1 or 5.2 it fails on assert (checked on
https://gcc.godbolt.org/)

Reply via email to