I don\'t quite understand why I don\'t get a division by zero exception:
int d = 0;
d /= d;
I expected
The behaviour of integer division by zero is undefined by the C++ standard. It is not required to throw an exception.
(Floating point division by zero is also undefined but IEEE754 defines it.)
Your compiler is optimising d /= d
to, effectively d = 1
which is a reasonable choice to make. It's allowed to make this optimisation since it's allowed to assume there is no undefined behaviour in your code - that is d
cannot possibly be zero.