| 1 |
/* { dg-additional-options "-fdiagnostics-text-art-charset=unicode" } */ |
| 2 |
/* { dg-skip-if "" { powerpc-ibm-aix* } } */ |
| 3 |
|
| 4 |
#include <string.h> |
| 5 |
|
| 6 |
void |
| 7 |
test_non_ascii () |
| 8 |
{ |
| 9 |
char buf[5]; |
| 10 |
strcpy (buf, "文字化け"); /* { dg-warning "stack-based buffer overflow" } */ |
| 11 |
/* { dg-warning "'__builtin_memcpy' writing 13 bytes into a region of size 5 overflows the destination" "" { target *-*-* } .-1 } */ |
| 12 |
} |
| 13 |
|
| 14 |
/* With unicode support, we should show the printable unicode chars. */ |
| 15 |
|
| 16 |
/* { dg-begin-multiline-output "" } |
| 17 |
|
| 18 |
┌─────┬─────┬─────┬────┬────┐┌────┬────┬────┬────┬────┬────┬────┬──────┐ |
| 19 |
│ [0] │ [1] │ [2] │[3] │[4] ││[5] │[6] │[7] │[8] │[9] │[10]│[11]│ [12] │ |
| 20 |
├─────┼─────┼─────┼────┼────┤├────┼────┼────┼────┼────┼────┼────┼──────┤ |
| 21 |
│0xe6 │0x96 │0x87 │0xe5│0xad││0x97│0xe5│0x8c│0x96│0xe3│0x81│0x91│ 0x00 │ |
| 22 |
├─────┴─────┴─────┼────┴────┴┴────┼────┴────┴────┼────┴────┴────┼──────┤ |
| 23 |
│ U+6587 │ U+5b57 │ U+5316 │ U+3051 │U+0000│ |
| 24 |
├─────────────────┼───────────────┼──────────────┼──────────────┼──────┤ |
| 25 |
│ 文 │ 字 │ 化 │ け │ NUL │ |
| 26 |
├─────────────────┴───────────────┴──────────────┴──────────────┴──────┤ |
| 27 |
│ string literal (type: 'char[13]') │ |
| 28 |
└──────────────────────────────────────────────────────────────────────┘ |
| 29 |
│ │ │ │ │ │ │ │ │ │ │ │ │ |
| 30 |
│ │ │ │ │ │ │ │ │ │ │ │ │ |
| 31 |
v v v v v v v v v v v v v |
| 32 |
┌─────┬────────────────┬────┐┌─────────────────────────────────────────┐ |
| 33 |
│ [0] │ ... │[4] ││ │ |
| 34 |
├─────┴────────────────┴────┤│ after valid range │ |
| 35 |
│ 'buf' (type: 'char[5]') ││ │ |
| 36 |
└───────────────────────────┘└─────────────────────────────────────────┘ |
| 37 |
├─────────────┬─────────────┤├────────────────────┬────────────────────┤ |
| 38 |
│ │ |
| 39 |
╭────────┴────────╮ ╭─────────┴─────────╮ |
| 40 |
│capacity: 5 bytes│ │overflow of 8 bytes│ |
| 41 |
╰─────────────────╯ ╰───────────────────╯ |
| 42 |
|
| 43 |
{ dg-end-multiline-output "" } */ |