I recently came accross some C++ code like the following:
if(test_1) if(test_2) { // Do stuff } else exit(0);
Is the behaviour of this code defined according to any standard (C, C++)?
Yes, it is defined. In C (and all similar languages as I know), the "dangling else" binds to the last free if, therefore this interpretation
if(test_1) { if(test_2) { } else { } }
is correct.