c-ubsan.c (ubsan_instrument_bounds): Don't instrument if TYPE_MAX_VALUE is NULL.

* c-ubsan.c (ubsan_instrument_bounds): Don't instrument if
	TYPE_MAX_VALUE is NULL.

	* gcc.dg/ubsan/bounds-1.c: New test.

From-SVN: r212552
This commit is contained in:
Marek Polacek 2014-07-15 11:06:07 +00:00 committed by Marek Polacek
parent 6ae5064251
commit 4d661eaacb
4 changed files with 20 additions and 1 deletions

View File

@ -1,3 +1,8 @@
2014-07-15 Marek Polacek <polacek@redhat.com>
* c-ubsan.c (ubsan_instrument_bounds): Don't instrument if
TYPE_MAX_VALUE is NULL.
2014-07-14 Jakub Jelinek <jakub@redhat.com>
PR middle-end/61294

View File

@ -265,7 +265,7 @@ ubsan_instrument_bounds (location_t loc, tree array, tree *index,
tree type = TREE_TYPE (array);
tree domain = TYPE_DOMAIN (type);
if (domain == NULL_TREE)
if (domain == NULL_TREE || TYPE_MAX_VALUE (domain) == NULL_TREE)
return NULL_TREE;
tree bound = TYPE_MAX_VALUE (domain);

View File

@ -1,3 +1,7 @@
2014-07-15 Marek Polacek <polacek@redhat.com>
* gcc.dg/ubsan/bounds-1.c: New test.
2014-06-15 Tobias Burnus <burnus@net-b.de>
* gfortran.dg/coarray_34.f90: New.

View File

@ -0,0 +1,10 @@
/* { dg-do compile } */
/* { dg-options "-fsanitize=bounds" } */
struct T { int c; char d[]; } t = { 1, "abcdefg" };
int
baz (int i)
{
return t.d[i];
}