| 1 |
/* { dg-additional-options "-fdiagnostics-text-art-charset=unicode" } */ |
| 2 |
|
| 3 |
#include <string.h> |
| 4 |
#include <stdlib.h> |
| 5 |
#include <stdint.h> |
| 6 |
|
| 7 |
void test8 (size_t size, size_t offset) |
| 8 |
{ |
| 9 |
char src[size]; |
| 10 |
char dst[size]; |
| 11 |
memcpy (dst, src, size + offset); /* { dg-line test8 } */ |
| 12 |
/* { dg-warning "over-read" "warning" { target *-*-* } test8 } */ |
| 13 |
/* { dg-warning "overflow" "warning" { target *-*-* } test8 } */ |
| 14 |
} |
| 15 |
|
| 16 |
/* { dg-begin-multiline-output "" } |
| 17 |
|
| 18 |
┌──────────────────────────────────────────────────────────────────────┐ |
| 19 |
│ read of 'size + offset' bytes │ |
| 20 |
└──────────────────────────────────────────────────────────────────────┘ |
| 21 |
^ ^ |
| 22 |
│ │ |
| 23 |
│ │ |
| 24 |
┌──────────────────────────────────┐┌──────────────────────────────────┐ |
| 25 |
│ buffer allocated on stack at (1) ││ after valid range │ |
| 26 |
└──────────────────────────────────┘└──────────────────────────────────┘ |
| 27 |
├────────────────┬─────────────────┤├────────────────┬─────────────────┤ |
| 28 |
│ │ |
| 29 |
╭─────────┴────────╮ ╭─────────────┴─────────────╮ |
| 30 |
│size: 'size' bytes│ │over-read of 'offset' bytes│ |
| 31 |
╰──────────────────╯ ╰───────────────────────────╯ |
| 32 |
|
| 33 |
{ dg-end-multiline-output "" } */ |
| 34 |
|
| 35 |
/* { dg-begin-multiline-output "" } |
| 36 |
|
| 37 |
┌──────────────────────────────────────────────────────────────────────┐ |
| 38 |
│ write of 'size + offset' bytes │ |
| 39 |
└──────────────────────────────────────────────────────────────────────┘ |
| 40 |
│ │ |
| 41 |
│ │ |
| 42 |
v v |
| 43 |
┌──────────────────────────────────┐┌──────────────────────────────────┐ |
| 44 |
│ buffer allocated on stack at (1) ││ after valid range │ |
| 45 |
└──────────────────────────────────┘└──────────────────────────────────┘ |
| 46 |
├────────────────┬─────────────────┤├────────────────┬─────────────────┤ |
| 47 |
│ │ |
| 48 |
╭───────────┴──────────╮ ╭─────────────┴────────────╮ |
| 49 |
│capacity: 'size' bytes│ │overflow of 'offset' bytes│ |
| 50 |
╰──────────────────────╯ ╰──────────────────────────╯ |
| 51 |
|
| 52 |
{ dg-end-multiline-output "" } */ |