Message ID | 2334390.fbpLepaxAm@polaris |
---|---|
State | New |
Headers | show |
Eric Botcazou <ebotcazou@adacore.com> writes: > This is a segfault on a degenerate bitfield case introduced by the rewrite of > the bitfield machinery. In Ada, we have bitfields of size zero and we ask the > middle-end to generate accesses to them. This doesn't work anymore because > get_best_mode now returns VOIDmode instead of QImode in this case, which > wreaks havoc later. > > The patchlet just restores the previous behaviour. It also makes the comment > describing the computation of bitregion_end_ more explicit, as the original > formulation is a bit terse on second reading, even for the reviewer. :-) > > Bootstrapped/regtested on x86-64/Linux, applied on the mainline as obvious. Thanks! Richard
Index: stor-layout.c =================================================================== --- stor-layout.c (revision 193985) +++ stor-layout.c (working copy) @@ -2648,10 +2648,14 @@ bit_field_mode_iterator { if (!bitregion_end_) { - /* We can assume that any aligned chunk of UNITS bits that overlaps - the bitfield is mapped and won't trap. */ - unsigned HOST_WIDE_INT units = MIN (align, MAX (BIGGEST_ALIGNMENT, - BITS_PER_WORD)); + /* We can assume that any aligned chunk of ALIGN bits that overlaps + the bitfield is mapped and won't trap, provided that ALIGN isn't + too large. The cap is the biggest required alignment for data, + or at least the word size. And force one such chunk at least. */ + unsigned HOST_WIDE_INT units + = MIN (align, MAX (BIGGEST_ALIGNMENT, BITS_PER_WORD)); + if (bitsize <= 0) + bitsize = 1; bitregion_end_ = bitpos + bitsize + units - 1; bitregion_end_ -= bitregion_end_ % units + 1; }