diff mbox series

[committed] add test for PR 92879

Message ID 34c193dd-c28c-47ff-7cdc-2402897255f5@gmail.com
State New
Headers show
Series [committed] add test for PR 92879 | expand

Commit Message

Martin Sebor Feb. 10, 2021, 9:46 p.m. UTC
The bug was resolved by r11-4745.  I pushed the test in r11-7180.

Martin
diff mbox series

Patch

commit 21c6ad7a12fecc4c85ac26289d9096379b550585
Author: Martin Sebor <msebor@redhat.com>
Date:   Wed Feb 10 14:42:22 2021 -0700

    Add test for PR tree-optimization/92879.
    
    gcc/testsuite/ChangeLog:
    
            PR tree-optimization/92879
            * g++.dg/warn/Warray-bounds-16.C: New test.

diff --git a/gcc/testsuite/g++.dg/warn/Warray-bounds-16.C b/gcc/testsuite/g++.dg/warn/Warray-bounds-16.C
new file mode 100644
index 00000000000..17b4d0d194e
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/Warray-bounds-16.C
@@ -0,0 +1,29 @@ 
+/* PR tree-optimization/92879 - incorrect warning of __builtin_memset
+   offset is out of the bounds on zero-size allocation and initialization
+   { dg-do compile }
+   { dg-options "-O2 -Wall -fdump-tree-optimized" } */
+
+inline void* operator new (__SIZE_TYPE__, void * v)
+{
+  return v;
+}
+
+struct S
+{
+  int* p;
+  int m;
+
+  S (int i)
+  {
+    m = i;
+    p = (int*) new unsigned char [sizeof (int) * m];
+
+    for (int i = 0; i < m; i++)
+      new (p + i) int ();
+  }
+};
+
+S a (0);
+
+/* Verify the loop has been eliminated.
+   { dg-final { scan-tree-dump-not "goto" "optimized" } } */