Debian Codegraph @

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

raw
1 /* Regression test for ICE with short values of
2 --param=analyzer-text-art-string-ellipsis-threshold=. */
3 /* { dg-additional-options "-fdiagnostics-text-art-charset=unicode --param=analyzer-text-art-string-ellipsis-threshold=0" } */
4 /* { dg-skip-if "" { powerpc-ibm-aix* } } */
5
6 #include <string.h>
7
8 void
9 test_non_ascii ()
10 {
11 char buf[9];
12 strcpy (buf, "Liberté\n"); /* { dg-warning "stack-based buffer overflow" } */
13 /* { dg-warning "'__builtin_memcpy' writing 10 bytes into a region of size 9 overflows the destination" "" { target *-*-* } .-1 } */
14 }
15
16 /* { dg-begin-multiline-output "" }
17
18 ┌──────┬──────┬──────┬──────┬──────┬──────┬────┬────┬──────┐┌─────────────────┐
19 │ [0] │ [1] │ [2] │ [3] │ [4] │ [5] │[6] │[7] │ [8] ││ [9] │
20 ├──────┼──────┼──────┼──────┼──────┼──────┼────┼────┼──────┤├─────────────────┤
21 │ 0x4c │ 0x69 │ 0x62 │ 0x65 │ 0x72 │ 0x74 │0xc3│0xa9│ 0x0a ││ 0x00 │
22 ├──────┼──────┼──────┼──────┼──────┼──────┼────┴────┼──────┤├─────────────────┤
23 │U+004c│U+0069│U+0062│U+0065│U+0072│U+0074│ U+00e9 │U+000a││ U+0000 │
24 ├──────┼──────┼──────┼──────┼──────┼──────┼─────────┼──────┤├─────────────────┤
25 │ L │ i │ b │ e │ r │ t │ é │ ││ NUL │
26 ├──────┴──────┴──────┴──────┴──────┴──────┴─────────┴──────┴┴─────────────────┤
27 │ string literal (type: 'char[10]') │
28 └─────────────────────────────────────────────────────────────────────────────┘
29 │ │ │ │ │ │ │ │ │ │
30 │ │ │ │ │ │ │ │ │ │
31 v v v v v v v v v v
32 ┌──────┬────────────────────────────────────────────┬──────┐┌─────────────────┐
33 │ [0] │ ... │ [8] ││ │
34 ├──────┴────────────────────────────────────────────┴──────┤│after valid range│
35 │ 'buf' (type: 'char[9]') ││ │
36 └──────────────────────────────────────────────────────────┘└─────────────────┘
37 ├────────────────────────────┬─────────────────────────────┤├────────┬────────┤
38 │ │
39 ╭────────┴────────╮ ╭─────────┴────────╮
40 │capacity: 9 bytes│ │overflow of 1 byte│
41 ╰─────────────────╯ ╰──────────────────╯
42
43 { dg-end-multiline-output "" } */