> This PR isn't really a C++ issue; it affects C as well, and presumably > all other languages. A comment a few lines down says > > /* Avoid returning a negative bitpos as this may wreak havoc later. */ > > but we were failing to avoid that in this case. > > Tested x86_64-pc-linux-gnu. OK for trunk/4.8?
Don't we want to error out instead of silently accepting this though? You could call valid_constant_size_p at the beginning of the block for example. The idea behind the existing trick is that the reference is within the bounds of the base object, i.e. the global offset (offset<<3 + bitpos) is positive, but the bitpos part is negative, so we rearrange it into ((offset-c>>3)<<3 + (bitpos+c)). Here the global offset is negative because it has overflowed so I'm not sure the rearrangement makes any sense. -- Eric Botcazou