re PR sanitizer/82353 (runtime ubsan crash)
authorJakub Jelinek <jakub@redhat.com>
Fri, 13 Oct 2017 20:19:17 +0000 (22:19 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 13 Oct 2017 20:19:17 +0000 (22:19 +0200)
PR sanitizer/82353
* g++.dg/ubsan/pr82353-2.C: New test.
* g++.dg/ubsan/pr82353-2-aux.cc: New file.
* g++.dg/ubsan/pr82353-2.h: New file.

From-SVN: r253744

gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/ubsan/pr82353-2-aux.cc [new file with mode: 0644]
gcc/testsuite/g++.dg/ubsan/pr82353-2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/ubsan/pr82353-2.h [new file with mode: 0644]

index 1a6ad0d7660475a1b8e1e55569009bf77a0dd77b..c6419c7f8f177ce4bff11aaed7d83f640617b04c 100644 (file)
@@ -1,3 +1,10 @@
+2017-10-13  Jakub Jelinek  <jakub@redhat.com>
+
+       PR sanitizer/82353
+       * g++.dg/ubsan/pr82353-2.C: New test.
+       * g++.dg/ubsan/pr82353-2-aux.cc: New file.
+       * g++.dg/ubsan/pr82353-2.h: New file.
+
 2017-10-13  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/81048
diff --git a/gcc/testsuite/g++.dg/ubsan/pr82353-2-aux.cc b/gcc/testsuite/g++.dg/ubsan/pr82353-2-aux.cc
new file mode 100644 (file)
index 0000000..75d466b
--- /dev/null
@@ -0,0 +1,32 @@
+// PR sanitizer/82353
+
+#include "pr82353-2.h"
+
+B a;
+E b;
+B C::c0;
+unsigned D::d0;
+
+void
+foo ()
+{
+  a.b1 = p.f2.e2.b1 = 5;
+}
+
+void
+bar ()
+{
+  int c = p.f2.e4.d1.a0 - -~p.f4 * 89;
+  q.c0.b0 = i > g * a.b0 * h - k % a.b1;
+  if ((~(m * j) && -~p.f4 * 90284000534361) % ~m * j)
+    b.e2.b0 << l << f;
+  o = -~p.f4 * 89;
+  int d = p.f4;
+  if (b.e2.b0)
+    b.e2.b1 = c;
+  bool e = ~-~p.f4;
+  a.b1 % e;
+  if (k / p.f2.e2.b1)
+    b.e4.d0 = g * a.b0 * h;
+  n = j;
+}
diff --git a/gcc/testsuite/g++.dg/ubsan/pr82353-2.C b/gcc/testsuite/g++.dg/ubsan/pr82353-2.C
new file mode 100644 (file)
index 0000000..31a35ac
--- /dev/null
@@ -0,0 +1,20 @@
+// PR sanitizer/82353
+// { dg-do run }
+// { dg-options "-fsanitize=undefined -fno-sanitize-recover=undefined -std=c++11 -O2 -w" }
+// { dg-additional-sources "pr82353-2-aux.cc" }
+
+#include "pr82353-2.h"
+
+unsigned long f, g;
+bool h, k, j, i;
+unsigned char l, m;
+short n;
+unsigned o;
+F p;
+
+int
+main ()
+{
+  foo ();
+  bar ();
+}
diff --git a/gcc/testsuite/g++.dg/ubsan/pr82353-2.h b/gcc/testsuite/g++.dg/ubsan/pr82353-2.h
new file mode 100644 (file)
index 0000000..4693d22
--- /dev/null
@@ -0,0 +1,31 @@
+extern unsigned long f, g;
+extern bool h, i, j, k;
+extern unsigned char l, m;
+extern short n;
+extern unsigned o;
+struct B {
+  short b0 : 27;
+  long b1 : 10;
+};
+struct A {
+  int a0 : 5;
+};
+struct C {
+  static B c0;
+};
+struct D {
+  static unsigned d0;
+  A d1;
+};
+struct E {
+  B e2;
+  D e4;
+};
+struct F {
+  E f2;
+  short f4;
+};
+extern F p;
+extern C q;
+void foo ();
+void bar ();