| 1 |
/* { dg-additional-options "-fdiagnostics-text-art-charset=ascii" } */ |
| 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 |
/* Without unicode support, we shouldn't 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 |
| string literal (type: 'char[13]') | |
| 26 |
+----------------------------------------------------------------------+ |
| 27 |
| | | | | | | | | | | | | |
| 28 |
| | | | | | | | | | | | | |
| 29 |
v v v v v v v v v v v v v |
| 30 |
+-----+----------------+----++-----------------------------------------+ |
| 31 |
| [0] | ... |[4] || | |
| 32 |
+-----+----------------+----+| after valid range | |
| 33 |
| 'buf' (type: 'char[5]') || | |
| 34 |
+---------------------------++-----------------------------------------+ |
| 35 |
|~~~~~~~~~~~~~+~~~~~~~~~~~~~||~~~~~~~~~~~~~~~~~~~~+~~~~~~~~~~~~~~~~~~~~| |
| 36 |
| | |
| 37 |
+--------+--------+ +---------+---------+ |
| 38 |
|capacity: 5 bytes| |overflow of 8 bytes| |
| 39 |
+-----------------+ +-------------------+ |
| 40 |
|
| 41 |
{ dg-end-multiline-output "" } */ |