From 8afb6a2cd6ec5e96306ff308f83247ddb1b68a9e Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Fri, 13 Oct 2017 22:19:17 +0200 Subject: [PATCH] re PR sanitizer/82353 (runtime ubsan crash) 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 | 7 +++++ gcc/testsuite/g++.dg/ubsan/pr82353-2-aux.cc | 32 +++++++++++++++++++++ gcc/testsuite/g++.dg/ubsan/pr82353-2.C | 20 +++++++++++++ gcc/testsuite/g++.dg/ubsan/pr82353-2.h | 31 ++++++++++++++++++++ 4 files changed, 90 insertions(+) create mode 100644 gcc/testsuite/g++.dg/ubsan/pr82353-2-aux.cc create mode 100644 gcc/testsuite/g++.dg/ubsan/pr82353-2.C create mode 100644 gcc/testsuite/g++.dg/ubsan/pr82353-2.h diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 1a6ad0d7660..c6419c7f8f1 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2017-10-13 Jakub Jelinek + + 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 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 index 00000000000..75d466b39bb --- /dev/null +++ b/gcc/testsuite/g++.dg/ubsan/pr82353-2-aux.cc @@ -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 index 00000000000..31a35ac3a02 --- /dev/null +++ b/gcc/testsuite/g++.dg/ubsan/pr82353-2.C @@ -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 index 00000000000..4693d2299f2 --- /dev/null +++ b/gcc/testsuite/g++.dg/ubsan/pr82353-2.h @@ -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 (); -- 2.30.2