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/70875] ICE in get_ubsan_type_info_for_type with -fsanitize=undefined


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

--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Seems like an overzealous assert:

diff --git a/gcc/ubsan.c b/gcc/ubsan.c
index 802341e..080f798 100644
--- a/gcc/ubsan.c
+++ b/gcc/ubsan.c
@@ -302,11 +302,14 @@ ubsan_source_location (location_t loc)
 static unsigned short
 get_ubsan_type_info_for_type (tree type)
 {
-  gcc_assert (TYPE_SIZE (type) && tree_fits_uhwi_p (TYPE_SIZE (type)));
   if (TREE_CODE (type) == REAL_TYPE)
-    return tree_to_uhwi (TYPE_SIZE (type));
+    {
+      gcc_assert (TYPE_SIZE (type) && tree_fits_uhwi_p (TYPE_SIZE (type)));
+      return tree_to_uhwi (TYPE_SIZE (type));
+    }
   else if (INTEGRAL_TYPE_P (type))
     {
+      gcc_assert (TYPE_SIZE (type) && tree_fits_uhwi_p (TYPE_SIZE (type)));
       int prec = exact_log2 (tree_to_uhwi (TYPE_SIZE (type)));
       gcc_assert (prec != -1);
       return (prec << 1) | !TYPE_UNSIGNED (type);

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