public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-6389] ubsan: Add another testcase for [0] array in the middle of struct [PR108894]
@ 2023-03-01  9:51 Jakub Jelinek
  0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2023-03-01  9:51 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:f72c8918416f67aad907752f1892c19eda12eecb

commit r13-6389-gf72c8918416f67aad907752f1892c19eda12eecb
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Wed Mar 1 10:49:38 2023 +0100

    ubsan: Add another testcase for [0] array in the middle of struct [PR108894]
    
    I think it is useful to cover also this, rather than just arrays at the
    flexible array member positions.
    
    2023-03-01  Jakub Jelinek  <jakub@redhat.com>
    
            PR sanitizer/108894
            * c-c++-common/ubsan/bounds-16.c: New test.

Diff:
---
 gcc/testsuite/c-c++-common/ubsan/bounds-16.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/gcc/testsuite/c-c++-common/ubsan/bounds-16.c b/gcc/testsuite/c-c++-common/ubsan/bounds-16.c
new file mode 100644
index 00000000000..0c27ff9cce4
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/ubsan/bounds-16.c
@@ -0,0 +1,15 @@
+/* PR sanitizer/108894 */
+/* { dg-do run } */
+/* { dg-options "-fsanitize=bounds -fsanitize-recover=bounds" } */
+/* { dg-output "index 1 out of bounds for type 'int \\\[\[*0-9x]*\\\]'\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output "\[^\n\r]*index 0 out of bounds for type 'int \\\[\[*0-9x]*\\\]'" } */
+
+struct S { int a; int b[0]; int c; } s;
+
+int
+main ()
+{
+  int *volatile p = &s.b[0];
+  p = &s.b[1];
+  int volatile q = s.b[0];
+}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-03-01  9:51 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-01  9:51 [gcc r13-6389] ubsan: Add another testcase for [0] array in the middle of struct [PR108894] Jakub Jelinek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).