Does the re-built-in constructor on the stack stack call a "pure virtual method"?

I wonder if any C ++ gurus can shed light on this strange situation. One example that comes with the Box2D physics engine breaks down with the message "pure virtual method", but only with a specific compiler (and only in the build version).

Box2D, as you may know, is a pretty solid piece of code, so I think this may be a problem with the compiler, especially considering that this only happens with this particular compiler. I am using mingw32 on Windows7:

> gcc.exe --version
gcc version 4.4.0 (GCC)

The following is a clipping from the relevant parts of Box2D. You can check the full source at:

b2Shape.h
b2CircleShape.h
b2CircleShape.cpp
SensorTest.h

//base class
class b2Shape
{
public:
    virtual ~b2Shape() {}
    virtual b2Shape* Clone(b2BlockAllocator* allocator) const = 0;
};


//sub class
class b2CircleShape : public b2Shape
{
public:
    b2CircleShape();
    b2Shape* Clone(b2BlockAllocator* allocator) const;
};

inline b2CircleShape::b2CircleShape() {}

b2Shape* b2CircleShape::Clone(b2BlockAllocator* allocator) const
{
    void* mem = allocator->Allocate(sizeof(b2CircleShape));
    b2CircleShape* clone = new (mem) b2CircleShape;
    *clone = *this;
    return clone;
}

Clone.

, , :

{
    b2CircleShape shape;
    shape.Clone(allocator); //ok
}
{
    b2CircleShape shape;
    shape.Clone(allocator); //"pure virtual method called"
}

, , - , , , , .

, , , b2CircleShape , . , , vtable , , . - , , vtable ...?

, , , , , .

№ 1 , . , , , . (, , "" . , ~ b2Shape() {}, , , ? , ...)

2, , 'inline' . , - , , . (: , )

, , , inline, , , , "inline"?

+5
2

error: no matching function for call to ‘operator new(long unsigned int, void*&)‘ g++ 4.5.2... , , , ... (new (mem) b2CircleShape)

, , , , ++. , , ( ), :

clone = new b2CircleShape(original);
+1

.

A) , , . B) , , gcc. , , . , MSVC.

, GCC Clang - , , , , . , , , .

.

0

All Articles