January 2020
Intermediate to advanced
454 pages
11h 25m
English
One of the easiest examples to demonstrate with UBSAN is the divide-by-zero error, as follows:
int main(void){ int n = 42; int d = 0; auto f = n/d;}
When this is run, we see the following:

In the preceding example, we create two integers (a numerator and a denominator) with the denominator set to 0. We then divide the numerator and the denominator resulting in a divide-by-zero error, which UBSAN detects and outputs as the program crashes.