aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2022-01-21 13:57:12 +0100
committerRichard Biener <rguenther@suse.de>2022-01-21 13:58:35 +0100
commitcaca8eddd9356777f5fe28454eb083b1779adc26 (patch)
treeb7eee55081994def8a666a3b9f438f3ae9a013b5 /gcc
parent9d7a84b96980d357bb9a3d368044fb18aab4aade (diff)
downloadgcc-caca8eddd9356777f5fe28454eb083b1779adc26.zip
gcc-caca8eddd9356777f5fe28454eb083b1779adc26.tar.gz
gcc-caca8eddd9356777f5fe28454eb083b1779adc26.tar.bz2
sanitizer/99673 - bad -Wstringop-overread diagnostic with asan
The testcase got fixed by lowering of &MEM[ptr + CST] to ptr + CST. 2022-01-21 Richard Biener <rguenther@suse.de> PR sanitizer/99673 * gcc.dg/asan/pr99673.c: New testcase.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/gcc.dg/asan/pr99673.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/asan/pr99673.c b/gcc/testsuite/gcc.dg/asan/pr99673.c
new file mode 100644
index 0000000..05857fd
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/asan/pr99673.c
@@ -0,0 +1,27 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-Wstringop-overread" } */
+
+struct B {
+ int i;
+ struct A {
+ short sa[8];
+ } a[2];
+};
+
+struct C {
+ char n, ax[];
+};
+
+struct D { int i, j, k; };
+
+int f (const short[8]);
+
+void g (struct C *pc, struct D *pd, int i)
+{
+ struct B *pb = (void *)pc->ax;
+ pd->i = pb->i;
+
+ const short *psa = pb->a[i].sa;
+ if (f (psa))
+ return;
+}