From ed5a5b38d8d069e22b2ac8f445d8b6911a21167f Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Thu, 12 Feb 2015 10:48:44 +0100 Subject: [PATCH] re PR sanitizer/65019 (Compare debug failure with -fsanitize=alignment,object-size,vptr -O3) PR sanitizer/65019 * ubsan.c (ubsan_expand_objsize_ifn): Always return true. * g++.dg/ubsan/pr65019.C: New test. From-SVN: r220641 --- gcc/ChangeLog | 3 +++ gcc/testsuite/ChangeLog | 3 +++ gcc/testsuite/g++.dg/ubsan/pr65019.C | 24 ++++++++++++++++++++++++ gcc/ubsan.c | 2 +- 4 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/ubsan/pr65019.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 723c62e2d15..60af263eebd 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,8 @@ 2015-02-12 Jakub Jelinek + PR sanitizer/65019 + * ubsan.c (ubsan_expand_objsize_ifn): Always return true. + PR tree-optimization/65014 * fold-const.c (fold_binary_loc): When creating {L,R}ROTATE_EXPR, use original second operand of arg0 or arg1 instead of diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index dfd7230fda4..01127e953c5 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2015-02-12 Jakub Jelinek + PR sanitizer/65019 + * g++.dg/ubsan/pr65019.C: New test. + PR tree-optimization/65014 * gcc.c-torture/compile/pr65014.c: New test. diff --git a/gcc/testsuite/g++.dg/ubsan/pr65019.C b/gcc/testsuite/g++.dg/ubsan/pr65019.C new file mode 100644 index 00000000000..a7f21a7d241 --- /dev/null +++ b/gcc/testsuite/g++.dg/ubsan/pr65019.C @@ -0,0 +1,24 @@ +// PR sanitizer/65019 +// { dg-do compile } +// { dg-options "-fsanitize=alignment,object-size,vptr -std=c++11 -O2 -fcompare-debug" } + +struct A { }; +struct B { }; +struct C final { + C (const A &, int); + static B *foo (const A &, int = 1); + virtual ~C (); + void *c; +}; + +B * +C::foo (const A &x, int y) +{ + C *d = new C (x, y); + if (d->c == nullptr) + delete d; +} + +C::~C () +{ +} diff --git a/gcc/ubsan.c b/gcc/ubsan.c index 2c1030c3169..fc3352f9949 100644 --- a/gcc/ubsan.c +++ b/gcc/ubsan.c @@ -987,7 +987,7 @@ ubsan_expand_objsize_ifn (gimple_stmt_iterator *gsi) /* Get rid of the UBSAN_OBJECT_SIZE call from the IR. */ unlink_stmt_vdef (stmt); gsi_remove (&gsi_orig, true); - return gsi_end_p (*gsi); + return true; } /* Cached __ubsan_vptr_type_cache decl. */ -- 2.30.2