diff options
Diffstat (limited to 'gcc/testsuite/gcc.dg/analyzer/out-of-bounds-diagram-10.c')
-rw-r--r-- | gcc/testsuite/gcc.dg/analyzer/out-of-bounds-diagram-10.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/analyzer/out-of-bounds-diagram-10.c b/gcc/testsuite/gcc.dg/analyzer/out-of-bounds-diagram-10.c new file mode 100644 index 0000000..4a7b8e3 --- /dev/null +++ b/gcc/testsuite/gcc.dg/analyzer/out-of-bounds-diagram-10.c @@ -0,0 +1,29 @@ +/* { dg-additional-options "-fdiagnostics-text-art-charset=unicode" } */ + +#include <stdint.h> +#include <stdlib.h> + +int32_t int_vla_write_element_symbolic_before_start (int32_t x, size_t n) +{ + int32_t arr[n]; /* { dg-message "\\(1\\) capacity: 'n \\* 4' bytes" } */ + arr[-2] = 42; /* { dg-warning "stack-based buffer underwrite" } */ +} + +/* { dg-begin-multiline-output "" } + + ┌───────────────────┐ + │write of '(int) 42'│ + └───────────────────┘ + │ + │ + v + ┌───────────────────┐ ┌────────────────────────────────┐ + │before valid range │ │buffer allocated on stack at (1)│ + └───────────────────┘ └────────────────────────────────┘ + ├─────────┬─────────┤├───────┬───────┤├───────────────┬────────────────┤ + │ │ │ + ╭─────────┴───────────╮ ╭───┴───╮ ╭───────────┴───────────╮ + │underwrite of 4 bytes│ │4 bytes│ │capacity: 'n * 4' bytes│ + ╰─────────────────────╯ ╰───────╯ ╰───────────────────────╯ + + { dg-end-multiline-output "" } */ |