Why exception caught without throwing in C++?

  c++, exception

I am running this program. As per my understanding, there should be a bad allocation exception raised within the try block and should cause a runtime failure. However, the program executes without any problem. I have the following questions:

  1. Why is there no run-time error?

  2. How does the control reach catch block even when no exceptions were thrown?

    #include <iostream>
    using namespace std;
    
    int main() {
        int b =4, *c = NULL, i=-1;
        try{
            c = new int [i]; 
            b--;
        }catch (exception& e){
            cout << "coming here" << endl;
            c = new int[1];
            b++;
        }
        cout << b << endl;
        return 0;
    }
    

Source: Windows Questions C++

LEAVE A COMMENT