re PR sanitizer/63690 (ICE: tree check: expected class 'expression', have 'constant' (string_cst) with -fsanitize=undefined)

PR sanitizer/63690
	* ubsan.c (instrument_object_size): Check for MEM_REF.

	* gcc.dg/ubsan/pr63690.c: New test.

From-SVN: r217778
This commit is contained in:
Marek Polacek 2014-11-19 14:32:02 +00:00 committed by Marek Polacek
parent 3b5b776210
commit c71a55f88d
4 changed files with 35 additions and 1 deletions

View File

@ -1,3 +1,8 @@
2014-11-19 Marek Polacek <polacek@redhat.com>
PR sanitizer/63690
* ubsan.c (instrument_object_size): Check for MEM_REF.
2014-11-19 Ilya Verbin <ilya.verbin@intel.com>
PR regression/63868

View File

@ -1,3 +1,8 @@
2014-11-19 Marek Polacek <polacek@redhat.com>
PR sanitizer/63690
* gcc.dg/ubsan/pr63690.c: New test.
2014-11-19 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
PR sanitizer/62132

View File

@ -0,0 +1,18 @@
/* PR sanitizer/63690 */
/* { dg-do compile } */
/* { dg-options "-fsanitize=undefined" } */
void
foo (void)
{
(*"c")++;
}
/* PR sanitizer/63690 */
/* { dg-do compile } */
/* { dg-options "-fsanitize=undefined" } */
void
foo (void)
{
(*"c")++;
}

View File

@ -1539,7 +1539,13 @@ instrument_object_size (gimple_stmt_iterator *gsi, bool is_lhs)
return;
bool decl_p = DECL_P (inner);
tree base = decl_p ? inner : TREE_OPERAND (inner, 0);
tree base;
if (decl_p)
base = inner;
else if (TREE_CODE (inner) == MEM_REF)
base = TREE_OPERAND (inner, 0);
else
return;
tree ptr = build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (t)), t);
while (TREE_CODE (base) == SSA_NAME)