The delete[] operator loses support for objects with destructor

When the delete[] operator is called explicitly, the support for objects with specific destructor is lost due to the following complications: This code should throw an unhandled exception when it tries to shrink the array of B's because the cookie isn't handled correctly.

/* */
using namespace std;

void*operator new[](size_t s){
    cout<<"Block size: "<<s<<endl;
    return malloc(s);
void operator delete[](void*p){
void operator delete[](void*p,size_t s){
    //It is required to know if the data type has a specific destructor to handle the cookie correctly.
    bool destructor=0;
    cout<<"New block size: "<<s<<endl;
    if(realloc(p,s)!=p)throw 0;

struct A{
    char a;


struct B{
    char b;


int main(){
    unsigned S=10,s=4;
    cout<<"Creating "<<S<<" A's"<<endl;
    A*a=new A[S];
    cout<<"Creating "<<S<<" B's"<<endl;
    B*b=new B[S];
    cout<<"Shrinking A to "<<s<<" elements"<<endl;
    operator delete[](a,sizeof(A)*s);
    cout<<"Shrinking B to "<<s<<" elements"<<endl;
    operator delete[](b,sizeof(B)*s);
    cout<<"Deleting A and B"<<endl;
    return 0;