http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58970

--- Comment #16 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to Bernd Edlinger from comment #15)
> (In reply to Bernd Edlinger from comment #14)
> > (In reply to Jakub Jelinek from comment #13)
> > > (In reply to Bernd Edlinger from comment #12)
> > > > I meant the change here is not necessary, because after the
> > > > if (*bitpos < 0) {...},
> > > > *offset can no longer be NULL, and I'd leave the assertion untouched.
> > > 
> > > Sure, if *bitpos was initially negative, then *offset won't be NULL there.
> > > But what I mean, are you sure that non-negative *bitpos will never be
> > > smaller than bitoffset if *offset is NULL?  Of course not on this 
> > > testcase...
> > 
> > If *bitpos is initially negative, I can proove that *offset is initially
> > NULL.
> 
> However we can be sure (to assert), that if offset is initially NULL,
> and *bitpos is initially >= 0, then
> the bit offset of the bitfield representative must be >= 0 too.
> because otherwiese, the bitfield would start at offset < 0 and end
> at an offset > 0. Which is not possible.

Why is it not possible?
struct __attribute__((packed, aligned (2))) T { int a : 31; int b : 1; };
void
foo (char *p)
{
  ((struct T *)(p - 2))->b = 1;
}
Here, *bitpos could be (at least in theory) 15, while bitoffset 31 and *offset
could still be NULL_TREE, because the bitpos fits in signed HWI.
Again, perhaps it is right now optimized into a MEM_REF and get_bit_range won't
see that, but can you rule that out just because of that?

Reply via email to