I have a sample code to test c++ virtual deconstructor like below:
#include <iostream>
class CA {
public:
virtual ~CA() {
std::cout<< "~CA" << std::endl;
}
};
class CB :public CA {
public:
virtual ~CB() {
std::cout<< "~CB" << std::endl;
}
};
int main(int argc, const char * argv[]) {
CA *pb = new CB[3];
delete []pb;
return 0;
}
in xcode this code print out result is :
~CA
~CA
~CA
but in other compilers like visual studio C++ and gcc the print out result is:
~CB
~CA
~CB
~CA
~CB
~CA
I think this is a dynamic delete array object with virtual deconstructor bug in xcode compiler 。 because the print result is not conform to C++ form。