On Mon, Dec 09, 2013 at 03:29:38PM +0100, Jakub Jelinek wrote: > On Mon, Dec 09, 2013 at 03:23:30PM +0100, Marek Polacek wrote: > > We ICEd on the following testcase with -fsanitize=null and vtable > > verification on, because gimple_call_fn returns NULL for UBSAN_* > > internal functions. Fixed by checking the result for NULL before > > accessing its TREE_CODE. > > > > Regtested/bootstrapped on x86_64-linux, ok for trunk? > > Ok. > > 2013-12-09 Marek Polacek <pola...@redhat.com> > > > > PR sanitizer/59415 > > * vtable-verify.c (verify_bb_vtables): Check the return value > > of gimple_call_fn. > > testsuite/ > > * g++.dg/ubsan/pr59415.C: New test. > > > > --- gcc/vtable-verify.c.mp 2013-12-09 13:11:24.045759854 +0100 > > +++ gcc/vtable-verify.c 2013-12-09 14:47:55.549415078 +0100 > > @@ -589,7 +589,7 @@ verify_bb_vtables (basic_block bb) > > if (gimple_code (stmt) == GIMPLE_CALL) > > While you are at this, can you please change the above into > if (is_gimple_call (stmt)) > , please? Thanks.
Thanks, will install this one then. 2013-12-09 Marek Polacek <pola...@redhat.com> PR sanitizer/59415 * vtable-verify.c (verify_bb_vtables): Check the return value of gimple_call_fn. Use is_gimple_call instead of gimple_code. testsuite/ * g++.dg/ubsan/pr59415.C: New test. --- gcc/vtable-verify.c.mp 2013-12-09 13:11:24.045759854 +0100 +++ gcc/vtable-verify.c 2013-12-09 15:32:09.461652068 +0100 @@ -586,10 +586,10 @@ verify_bb_vtables (basic_block bb) stmt = gsi_stmt (gsi_virtual_call); /* Count virtual calls. */ - if (gimple_code (stmt) == GIMPLE_CALL) + if (is_gimple_call (stmt)) { tree fncall = gimple_call_fn (stmt); - if (TREE_CODE (fncall) == OBJ_TYPE_REF) + if (fncall && TREE_CODE (fncall) == OBJ_TYPE_REF) total_num_virtual_calls++; } --- gcc/testsuite/g++.dg/ubsan/pr59415.C.mp 2013-12-09 14:44:59.757670282 +0100 +++ gcc/testsuite/g++.dg/ubsan/pr59415.C 2013-12-09 14:45:45.918858550 +0100 @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-fsanitize=null -Wall -fvtable-verify=std" } */ + +void +foo (void) +{ + throw 0; +} Marek