From 7cd200f63f80396e9ddfe163a3fed86fd2aed672 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Mon, 27 Mar 2017 10:25:01 +0200 Subject: re PR sanitizer/80168 (ICE in make_decl_rtl, at varasm.c:1311 w/ VLA and -fsanitize=address) PR sanitizer/80168 * asan.c (instrument_derefs): Copy over last operand from original COMPONENT_REF to the new COMPONENT_REF with DECL_BIT_FIELD_REPRESENTATIVE. * ubsan.c (instrument_object_size): Likewise. * gcc.dg/asan/pr80168.c: New test. From-SVN: r246492 --- gcc/ChangeLog | 8 ++++++++ gcc/asan.c | 3 ++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/asan/pr80168.c | 12 ++++++++++++ gcc/ubsan.c | 2 +- 5 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/asan/pr80168.c (limited to 'gcc') diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 8dcd897..f2f40b8 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2017-03-27 Jakub Jelinek + + PR sanitizer/80168 + * asan.c (instrument_derefs): Copy over last operand from + original COMPONENT_REF to the new COMPONENT_REF with + DECL_BIT_FIELD_REPRESENTATIVE. + * ubsan.c (instrument_object_size): Likewise. + 2017-03-27 Richard Biener PR tree-optimization/80170 diff --git a/gcc/asan.c b/gcc/asan.c index a13679d..f1098cb 100644 --- a/gcc/asan.c +++ b/gcc/asan.c @@ -1868,7 +1868,8 @@ instrument_derefs (gimple_stmt_iterator *iter, tree t, tree repr = DECL_BIT_FIELD_REPRESENTATIVE (TREE_OPERAND (t, 1)); instrument_derefs (iter, build3 (COMPONENT_REF, TREE_TYPE (repr), TREE_OPERAND (t, 0), repr, - NULL_TREE), location, is_store); + TREE_OPERAND (t, 2)), + location, is_store); return; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0b04afe..3a8e22e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-03-27 Jakub Jelinek + + PR sanitizer/80168 + * gcc.dg/asan/pr80168.c: New test. + 2017-03-27 Richard Biener PR tree-optimization/80170 diff --git a/gcc/testsuite/gcc.dg/asan/pr80168.c b/gcc/testsuite/gcc.dg/asan/pr80168.c new file mode 100644 index 0000000..de23345 --- /dev/null +++ b/gcc/testsuite/gcc.dg/asan/pr80168.c @@ -0,0 +1,12 @@ +/* PR sanitizer/80168 */ +/* { dg-do compile } */ + +int a; + +int +foo (void) +{ + struct S { int c[a]; int q : 8; int e : 4; } f; + f.e = 4; + return f.e; +} diff --git a/gcc/ubsan.c b/gcc/ubsan.c index 17965ef..323c1cc 100644 --- a/gcc/ubsan.c +++ b/gcc/ubsan.c @@ -1772,7 +1772,7 @@ instrument_object_size (gimple_stmt_iterator *gsi, bool is_lhs) { tree repr = DECL_BIT_FIELD_REPRESENTATIVE (TREE_OPERAND (t, 1)); t = build3 (COMPONENT_REF, TREE_TYPE (repr), TREE_OPERAND (t, 0), - repr, NULL_TREE); + repr, TREE_OPERAND (t, 2)); } break; case ARRAY_REF: -- cgit v1.1