It does occur - I just tested it.
int main()
{
int i=0;
try{
int k=9/i;
}
catch(...)
{
std::cout<<"exception occurs"<<std::endl; }
}
It didn't occur in your original version, because the compiler looked at the code, saw a constant divided by a constant and optimised it to a constant value. And then complained about the divide by zero at compile time instead of run time.