Debian Codegraph @

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

raw
1 /* Test of -fanalyzer-debug-text-art. */
2
3 /* { dg-additional-options "-fdiagnostics-text-art-charset=ascii -fanalyzer-debug-text-art" } */
4
5 #include <stdint.h>
6
7 int32_t arr[10];
8
9 void int_arr_write_element_after_end_off_by_one(int32_t x)
10 {
11 arr[10] = x; /* { dg-line line } */
12 }
13 /* { dg-warning "buffer overflow" "warning" { target *-*-* } line } */
14 /* { dg-message "valid subscripts for 'arr' are '\\\[0\\\]' to '\\\[9\\\]'" "valid subscript note" { target *-*-* } line } */
15
16 /* { dg-begin-multiline-output "" }
17
18 +---------+-----------+-----------+---+--------------------------------+
19 | tc0 | tc1 | tc2 |tc3| tc4 |
20 +---------+-----------+-----------+---+--------------------------------+
21 |bytes 0-3|bytes 4-35 |bytes 36-39| | bytes 40-43 |
22 +---------+-----------+-----------+ +--------------------------------+
23 +--------------------------------+
24 |write from 'x' (type: 'int32_t')|
25 +--------------------------------+
26 |
27 |
28 v
29 +---------+-----------+-----------+ +--------------------------------+
30 | [0] | ... | [9] | | |
31 +---------+-----------+-----------+ | after valid range |
32 | 'arr' (type: 'int32_t[10]') | | |
33 +---------------------------------+ +--------------------------------+
34 |~~~~~~~~~~~~~~~~+~~~~~~~~~~~~~~~~| |~~~~~~~~~~~~~~~+~~~~~~~~~~~~~~~~|
35 | |
36 +---------+--------+ +---------+---------+
37 |capacity: 40 bytes| |overflow of 4 bytes|
38 +------------------+ +-------------------+
39
40 { dg-end-multiline-output "" } */