This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug sanitizer/70875] ICE in get_ubsan_type_info_for_type with -fsanitize=undefined
- 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: Thu, 05 May 2016 19:55:13 +0000
- Subject: [Bug sanitizer/70875] ICE in get_ubsan_type_info_for_type with -fsanitize=undefined
- Auto-submitted: auto-generated
- References: <bug-70875-4 at http dot gcc dot gnu dot org/bugzilla/>
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);