On Fri, Sep 20, 2013 at 10:22:43AM +0200, Marek Polacek wrote: > > --- gcc/ubsan.c.mp 2013-09-16 18:13:01.075903156 +0200 > > +++ gcc/ubsan.c 2013-09-16 18:13:20.514974154 +0200 > > @@ -233,7 +233,13 @@ ubsan_source_location (location_t loc) > > static unsigned short > > get_ubsan_type_info_for_type (tree type) > > { > > - int prec = exact_log2 (TYPE_PRECISION (type)); > > + int prec = TYPE_PRECISION (type); > > + > > + /* Handle bit-fields. */ > > + if (compare_tree_int (TYPE_SIZE (type), prec) == 1) > > + prec = tree_low_cst (TYPE_SIZE (type), 1);
Makes me wonder why you are using then TYPE_PRECISION at all, when you actually want to use TYPE_SIZE. Note that TYPE_SIZE can be NULL (for incomplete types) or non-constant (VLAs) or big enough not to fit into a HWI. But you are so far dealing only with integral/scalar float types, right? So perhaps just gcc_assert (TYPE_SIZE (type) && host_integerp (TYPE_SIZE (type), 1) or something. > > + > > + prec = exact_log2 (prec); > > if (prec == -1) > > error ("unexpected size of type %qT", type); This sounds like it should be gcc_assert (prec != -1); or sorry, it doesn't look like a bug in user program if we hit that. Jakub