I ran into a problem with the VS debugger with the above code:
class Animal {
public:
};
class Stupid {
public:
};
class Dog : public Stupid, public Animal {
public:
};
int main() {
std::unique_ptr<Animal> animal = std::unique_ptr<Dog>(new Dog());
animal.reset();
return 0;
}
This code throws an error after executing "animal.reset ()" involving "ntdl.dll" and "wntdll.pdb".
Here are the expressions that generated the assertion errors using the MSVC runtime library if I click ignore several (3) times:
1- _CrtIsValidHeapPointer(block)
2- is_block_type_valid(header->_block_use)
3- HEAP CORRUPTION DETECTED: before Free block (
But if I change the inheritance of Dog, like this:
class Dog : public Animal, public Stupid {
public:
};
The code is working fine.
I only have this error in visual studio 2017, I tried with Ideone , Android Studio, and it works fine, regardless of the order of inheritance.
source
share