HP aC++/HP C A.06.20 Programmer's Guide

all - Enables out-of-bounds checks for both arrays and pointers. This is equal to
+check=bounds:array +check=bounds:pointer.
none - Disables out-of-bounds checks.
+check=bounds (with no suboption) is equal to +check=bounds:array. This may
change in the future to also include +check=bounds:pointer.
When +check=all is specified, it enables +check=bounds:array only. To enable
the pointer out-of-bounds check, you must explicitly specify
+check=bounds:pointer.
You can combine +check=bounds:[pointer | all] with all other +check options,
except for +check=globals (which would be ignored in this case).
Also see the +check=malloc and the +check=stack options for related runtime
checks for heap and stack objects.
Example:
This example uses +check=bounds:pointer to find a program bug:
$ cat rttest3.c 1 #include <stdio.h>
2 #include <memory.h>
3 #include <stdlib.h>
4 5 int a[10];
6 char b[10];
7 int *ip = &a[0]; // points to global array
8
9 int i;
10
11 void *foo(int n)
12 {
13 return malloc(n * sizeof(int));
14 }
15
16 int main(int argc, char **argv)
17 {
18 int j; // uninitialized variable
19
20 int *lp = (int*)foo(10); // points to heap object
21
22 // out of bound if "a.out 10"
23 if (argc > 1) {
24 i = atoi(argv[1]);
25 }
26
27 memset(b, 'a', i);
28
29 lp[i] = i;
30
31 ip[i+1] = i+1;
32
33 printf("lp[%d]=%d, ip[%d]=%d, ip[j=%d]=%d\n",
Runtime Checking Options 101