I have encountered a strange bug in my program which was solved by making a destructor non-inline:
File a.h
class A {
...
inline virtual ~A(){}
};
File b.h
class B : public A {
...
virtual ~B(); // Defined in cpp file
};
Client code file.cpp
#include "a.h"
#include "b.h"
...
auto x = std::make_unique<B>();
The call to make_unique throws a bad_alloc exception. When I make ~A() non-inline and ~B() override, it stops throwing. Does anyone have any idea why it works? Another solution I found was to make printouts with cout in A and B's destructors. I have tried to simplify the relatively complex code as much as possible, so I must have left some crucial information out. What I want to know is what could have caused this strange behavior? Is overriding inline destructors with non-inline destructors somehow ambiguous?