Debian Codegraph @

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

raw
1 /* Integration test of how the execution path looks for
2 -Wanalyzer-out-of-bounds with a symbolic size. */
3
4 /* { dg-additional-options "-fdiagnostics-show-path-depths" } */
5 /* { dg-additional-options "-fdiagnostics-path-format=inline-events -fdiagnostics-show-caret" } */
6
7 #include <stdint.h>
8 #include <stdlib.h>
9
10 void int_vla_write_element_after_end_off_by_one(int32_t x, size_t n)
11 {
12 int32_t arr[n];
13
14 arr[n] = x; /* { dg-warning "stack-based buffer overflow" } */
15 }
16
17 /* { dg-begin-multiline-output "" }
18 arr[n] = x;
19 ~~~~~~~^~~
20 'int_vla_write_element_after_end_off_by_one': events 1-2 (depth 1)
21 int32_t arr[n];
22 ^~~
23 |
24 (1) capacity: 'n * 4' bytes
25 { dg-end-multiline-output "" } */
26 /* { dg-begin-multiline-output "" }
27 arr[n] = x;
28 ~~~~~~~~~~
29 |
30 (2) write of 4 bytes at offset 'n * 4' exceeds the buffer
31 { dg-end-multiline-output "" } */