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?

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)
         {
           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

Reply via email to