| 1 |
/* { dg-additional-options "-fdiagnostics-text-art-charset=unicode" } */ |
| 2 |
|
| 3 |
#include <stdint.h> |
| 4 |
#include <stdlib.h> |
| 5 |
|
| 6 |
int32_t int_vla_write_element_symbolic_before_start (int32_t x, size_t n) |
| 7 |
{ |
| 8 |
int32_t arr[n]; /* { dg-message "\\(1\\) capacity: 'n \\* 4' bytes" } */ |
| 9 |
arr[-2] = 42; /* { dg-warning "stack-based buffer underwrite" } */ |
| 10 |
} |
| 11 |
|
| 12 |
/* { dg-begin-multiline-output "" } |
| 13 |
|
| 14 |
┌───────────────────────┐ |
| 15 |
│write of '(int32_t) 42'│ |
| 16 |
└───────────────────────┘ |
| 17 |
│ |
| 18 |
│ |
| 19 |
v |
| 20 |
┌───────────────────────┐ ┌────────────────────────────────┐ |
| 21 |
│ before valid range │ │buffer allocated on stack at (1)│ |
| 22 |
└───────────────────────┘ └────────────────────────────────┘ |
| 23 |
├───────────┬───────────┤├─────┬─────┤├───────────────┬────────────────┤ |
| 24 |
│ │ │ |
| 25 |
╭──────────┴──────────╮ ╭───┴───╮ ╭───────────┴───────────╮ |
| 26 |
│underwrite of 4 bytes│ │4 bytes│ │capacity: 'n * 4' bytes│ |
| 27 |
╰─────────────────────╯ ╰───────╯ ╰───────────────────────╯ |
| 28 |
|
| 29 |
{ dg-end-multiline-output "" } */ |