September 2012
Intermediate to advanced
512 pages
12h 41m
English
By “bounds checking” we mean to verify that an integer x is within two bounds a and b—that is, that
a ≤ x ≤ b.
We first assume that all quantities are signed integers.
An important application is the checking of array indexes. For example, suppose a one-dimensional array A can be indexed by values from 1 to 10. Then, for a reference A(i), a compiler might generate code to check that
1 ≤ i ≤ 10
and to branch or trap if this is not the case. In this section we show that this check can be done with a single comparison, by performing the equivalent check [PL8]:
This is probably better code, ...
Read now
Unlock full access