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
This commit is contained in:
Jakub Jelinek 2017-10-13 22:19:17 +02:00 committed by Jakub Jelinek
parent 39382c092e
commit 8afb6a2cd6
4 changed files with 90 additions and 0 deletions

View 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

View file

@ -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;
}

View file

@ -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 ();
}

View file

@ -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 ();