This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug sanitizer/61591] Undefined behavior sanitizer does not catch builtin_unreachable's from impossible devirtualization


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61591

--- Comment #7 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
And if it is:

diff --git a/gcc/sanopt.c b/gcc/sanopt.c
index ce9fbcf..77b88f7 100644
--- a/gcc/sanopt.c
+++ b/gcc/sanopt.c
@@ -646,20 +646,21 @@ pass_sanopt::execute (function *fun)
           break;
         }
         }
-      else if (gimple_call_builtin_p (stmt, BUILT_IN_NORMAL))
+      else
         {
           tree callee = gimple_call_fndecl (stmt);
-          switch (DECL_FUNCTION_CODE (callee))
-        {
-        case BUILT_IN_UNREACHABLE:
-          if (flag_sanitize & SANITIZE_UNREACHABLE
-              && !lookup_attribute ("no_sanitize_undefined",
-                        DECL_ATTRIBUTES (fun->decl)))
-            no_next = ubsan_instrument_unreachable (&gsi);
-          break;
-        default:
-          break;
-        }
+          if (callee && DECL_BUILT_IN_CLASS (callee) == BUILT_IN_NORMAL)
+        switch (DECL_FUNCTION_CODE (callee))
+          {
+          case BUILT_IN_UNREACHABLE:
+            if (flag_sanitize & SANITIZE_UNREACHABLE
+            && !lookup_attribute ("no_sanitize_undefined",
+                          DECL_ATTRIBUTES (fun->decl)))
+              no_next = ubsan_instrument_unreachable (&gsi);
+            break;
+          default:
+            break;
+          }
         }

       if (dump_file && (dump_flags & TDF_DETAILS))


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]