| 1 |
/* { dg-additional-options "-fdiagnostics-text-art-charset=unicode" } */ |
| 2 |
/* { dg-skip-if "" { powerpc-ibm-aix* } } */ |
| 3 |
|
| 4 |
#include <string.h> |
| 5 |
|
| 6 |
void test (void) |
| 7 |
{ |
| 8 |
char buf[11]; |
| 9 |
strcpy (buf, "サツキ"); |
| 10 |
strcat (buf, "メイ"); /* { dg-warning "stack-based buffer overflow" } */ |
| 11 |
/* { dg-message "write of 5 bytes to beyond the end of 'buf'" "" { target *-*-* } .-1 } */ |
| 12 |
} |
| 13 |
|
| 14 |
/* { dg-begin-multiline-output "" } |
| 15 |
┌──────┬────┐┌────┬────┬────┬────┬──────┐ |
| 16 |
│ [0] │[1] ││[2] │[3] │[4] │[5] │ [6] │ |
| 17 |
├──────┼────┤├────┼────┼────┼────┼──────┤ |
| 18 |
│ 0xe3 │0x83││0xa1│0xe3│0x82│0xa4│ 0x00 │ |
| 19 |
├──────┴────┴┴────┼────┴────┴────┼──────┤ |
| 20 |
│ U+30e1 │ U+30a4 │U+0000│ |
| 21 |
├─────────────────┼──────────────┼──────┤ |
| 22 |
│ メ │ イ │ NUL │ |
| 23 |
├─────────────────┴──────────────┴──────┤ |
| 24 |
│ string literal (type: 'char[7]') │ |
| 25 |
└───────────────────────────────────────┘ |
| 26 |
│ │ │ │ │ │ │ |
| 27 |
│ │ │ │ │ │ │ |
| 28 |
v v v v v v v |
| 29 |
┌────┬────────────────────────────────────────┬──────┬────┐┌──────────────────────────┐ |
| 30 |
│[0] │ ... │ [9] │[10]││ │ |
| 31 |
├────┼────┬────┬────┬────┬────┬────┬────┬────┬┼──────┼────┘│ │ |
| 32 |
│0xe3│0x82│0xb5│0xe3│0x83│0x84│0xe3│0x82│0xad││ 0x00 │ │ │ |
| 33 |
├────┴────┴────┼────┴────┴────┼────┴────┴────┤├──────┤ │ │ |
| 34 |
│ U+30b5 │ U+30c4 │ U+30ad ││U+0000│ │ after valid range │ |
| 35 |
├──────────────┼──────────────┼──────────────┤├──────┤ │ │ |
| 36 |
│ サ │ ツ │ キ ││ NUL │ │ │ |
| 37 |
├──────────────┴──────────────┴──────────────┴┴──────┴────┐│ │ |
| 38 |
│ 'buf' (type: 'char[11]') ││ │ |
| 39 |
└─────────────────────────────────────────────────────────┘└──────────────────────────┘ |
| 40 |
├────────────────────────────┬────────────────────────────┤├────────────┬─────────────┤ |
| 41 |
│ │ |
| 42 |
╭─────────┴────────╮ ╭─────────┴─────────╮ |
| 43 |
│capacity: 11 bytes│ │overflow of 5 bytes│ |
| 44 |
╰──────────────────╯ ╰───────────────────╯ |
| 45 |
{ dg-end-multiline-output "" } */ |