This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug sanitizer/61591] Undefined behavior sanitizer does not catch builtin_unreachable's from impossible devirtualization
- From: "mpolacek at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 08 Dec 2014 12:19:58 +0000
- Subject: [Bug sanitizer/61591] Undefined behavior sanitizer does not catch builtin_unreachable's from impossible devirtualization
- Auto-submitted: auto-generated
- References: <bug-61591-4 at http dot gcc dot gnu dot org/bugzilla/>
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))