This is not true. What usually happens is that the CPU will throw an internal exception of some kind when the division instruction has 0 for the operand, which calls the interrupt handler, which reads the state of the various registers on the processor and processes it, usually by converting it to a signal that is sent back to the program and processed by any registered signal handlers. For most UNIX-like operating systems, they get SIGFPE.
While the behavior may change (for example, on some processors you can say that the CPU does not throw an exception, as a rule, they just put some kind of clamped value as 0 or MAXINT), this change is usually due to differences in the OS, CPUm and the runtime, not the compiler.
source
share