Debian Codegraph @

gcc/testsuite/gcc.dg/analyzer/out-of-bounds-multiline-1.c

raw
1 /* Integration test of how the execution path looks for
2 -Wanalyzer-out-of-bounds. */
3
4 /* { dg-additional-options "-fdiagnostics-show-path-depths" } */
5 /* { dg-additional-options "-fdiagnostics-path-format=inline-events -fdiagnostics-show-caret" } */
6
7
8 #include <stdint.h>
9
10 int32_t arr[10];
11
12 void int_arr_write_element_after_end_off_by_one(int32_t x)
13 {
14 arr[10] = x; /* { dg-line line } */
15 }
16 /* { dg-warning "buffer overflow" "warning" { target *-*-* } line } */
17 /* { dg-message "valid subscripts for 'arr' are '\\\[0\\\]' to '\\\[9\\\]'" "valid subscript note" { target *-*-* } line } */
18
19
20 /* { dg-begin-multiline-output "" }
21 arr[10] = x;
22 ~~~~~~~~^~~
23 event 1 (depth 0)
24 |
25 | int32_t arr[10];
26 | ^~~
27 | |
28 | (1) capacity: 40 bytes
29 |
30 +--> 'int_arr_write_element_after_end_off_by_one': event 2 (depth 1)
31 |
32 | arr[10] = x;
33 | ~~~~~~~~^~~
34 | |
35 | (2) out-of-bounds write from byte 40 till byte 43 but 'arr' ends at byte 40
36 |
37 { dg-end-multiline-output "" } */