Hi! Similar problem to the recently fixed UBSAN_VPTR lowering, ubsan_expand_objsize_ifn sets *gsi to the first stmt in a new bb after splitting block after UBSAN_OBJECT_SIZE, which is the next stmt that should be processed, so we should always return no_next = true to avoid gsi_next on it before it will be processed.
Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2015-02-12 Jakub Jelinek <ja...@redhat.com> PR sanitizer/65019 * ubsan.c (ubsan_expand_objsize_ifn): Always return true. * g++.dg/ubsan/pr65019.C: New test. --- gcc/ubsan.c.jj 2015-02-10 22:58:55.000000000 +0100 +++ gcc/ubsan.c 2015-02-11 17:20:36.313063536 +0100 @@ -987,7 +987,7 @@ ubsan_expand_objsize_ifn (gimple_stmt_it /* 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. */ --- gcc/testsuite/g++.dg/ubsan/pr65019.C.jj 2015-02-11 17:26:44.832959016 +0100 +++ gcc/testsuite/g++.dg/ubsan/pr65019.C 2015-02-11 17:26:23.000000000 +0100 @@ -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 () +{ +} Jakub