IRA: Ignore debug insns for uses in split_live_ranges_for_shrink_wrap. [PR116179]
[official-gcc.git] / gcc / testsuite / c-c++-common / analyzer / out-of-bounds-diagram-strcat-2.c
blobb129518d759f7d9e71d3a8174cb67030b254bdb6
1 /* { dg-additional-options "-fdiagnostics-text-art-charset=unicode" } */
2 /* { dg-skip-if "" { powerpc-ibm-aix* } } */
4 #include <string.h>
6 #define LOREM_IPSUM \
7 "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod" \
8 " tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim" \
9 " veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea" \
10 " commodo consequat. Duis aute irure dolor in reprehenderit in voluptate" \
11 " velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint" \
12 " occaecat cupidatat non proident, sunt in culpa qui officia deserunt" \
13 " mollit anim id est laborum."
15 void test (void)
17 char buf[500];
18 strcpy (buf, LOREM_IPSUM);
19 strcat (buf, LOREM_IPSUM); /* { dg-warning "stack-based buffer overflow" } */
22 /* { dg-begin-multiline-output "" }
24 ┌─────┬───┬───┬───┬───┬───┬────────┬─────┬─────┬─────┬─────┬─────┬─────┐
25 │ [0] │[1]│[2]│[3]│[4]│[5]│ │[440]│[441]│[442]│[443]│[444]│[445]│
26 ├─────┼───┼───┼───┼───┼───┤ ... ├─────┼─────┼─────┼─────┼─────┼─────┤
27 │ 'L' │'o'│'r'│'e'│'m'│' '│ │ 'o' │ 'r' │ 'u' │ 'm' │ '.' │ NUL │
28 ├─────┴───┴───┴───┴───┴───┴────────┴─────┴─────┴─────┴─────┴─────┴─────┤
29 │ string literal (type: 'char[446]') │
30 └──────────────────────────────────────────────────────────────────────┘
31 │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
32 │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
33 v v v v v v v v v v v v v v v
34 ┌───┬────────────────────────────────────────────┬─────┬────────────────────┬─────┐┌────────────────────────────────────┐
35 │[0]│ ... │[445]│ ... │[499]││ │
36 ├───┼───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬┼─────┼────────────────────┴─────┘│ │
37 │'L'│'o'│'r'│'e'│'m'│' '│...│'o'│'r'│'u'│'m'│'.'││ NUL │ │ after valid range │
38 ├───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴┴─────┴──────────────────────────┐│ │
39 │ 'buf' (type: 'char[500]') ││ │
40 └─────────────────────────────────────────────────────────────────────────────────┘└────────────────────────────────────┘
41 ├────────────────────────────────────────┬────────────────────────────────────────┤├─────────────────┬──────────────────┤
42 │ │
43 ╭─────────┴─────────╮ ╭──────────┴──────────╮
44 │capacity: 500 bytes│ │overflow of 391 bytes│
45 ╰───────────────────╯ ╰─────────────────────╯
47 { dg-end-multiline-output "" { target c } } */
49 /* { dg-begin-multiline-output "" }
51 ┌─────┬───┬───┬───┬───┬───┬────────┬─────┬─────┬─────┬─────┬─────┬─────┐
52 │ [0] │[1]│[2]│[3]│[4]│[5]│ │[440]│[441]│[442]│[443]│[444]│[445]│
53 ├─────┼───┼───┼───┼───┼───┤ ... ├─────┼─────┼─────┼─────┼─────┼─────┤
54 │ 'L' │'o'│'r'│'e'│'m'│' '│ │ 'o' │ 'r' │ 'u' │ 'm' │ '.' │ NUL │
55 ├─────┴───┴───┴───┴───┴───┴────────┴─────┴─────┴─────┴─────┴─────┴─────┤
56 │ string literal (type: 'const char[446]') │
57 └──────────────────────────────────────────────────────────────────────┘
58 │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
59 │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
60 v v v v v v v v v v v v v v v
61 ┌───┬────────────────────────────────────────────┬─────┬────────────────────┬─────┐┌────────────────────────────────────┐
62 │[0]│ ... │[445]│ ... │[499]││ │
63 ├───┼───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬┼─────┼────────────────────┴─────┘│ │
64 │'L'│'o'│'r'│'e'│'m'│' '│...│'o'│'r'│'u'│'m'│'.'││ NUL │ │ after valid range │
65 ├───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴┴─────┴──────────────────────────┐│ │
66 │ 'char buf [500]' (type: 'char[500]') ││ │
67 └─────────────────────────────────────────────────────────────────────────────────┘└────────────────────────────────────┘
68 ├────────────────────────────────────────┬────────────────────────────────────────┤├─────────────────┬──────────────────┤
69 │ │
70 ╭─────────┴─────────╮ ╭──────────┴──────────╮
71 │capacity: 500 bytes│ │overflow of 391 bytes│
72 ╰───────────────────╯ ╰─────────────────────╯
74 { dg-end-multiline-output "" { target c++ } } */