http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58970
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> --- (In reply to Bernd Edlinger from comment #4) > Created attachment 31145 [details] > For a possible patch. > > This patch is assuming that a statement like "s->mode[-1].b = 0;" > is basically invoking undefined behaviour, so it should not matter > if we have correct bitregion_start/end values or just set them to zero > in this case. That doesn't look safe, negative rbitpos is not necessarily undefined behavior. Can't you get the same with say struct S { unsigned char s : 1; }; ... void function(struct S *p) { p[-1].s = 0; } Apparently get_inner_reference only gives negative bitpos if offset is NULL_TREE, otherwise it adjusts offset such that the bitpos is positive. I wonder if get_bit_range shouldn't do the same thing if it detects *bitpos is negative and *offset is NULL_TREE before doing the bitoffset > *bitpos comparison. It might be as easy as replacing the gcc_assert (*offset != NULL_TREE); with if (*offset == NULL_TREE) *offset = size_int (0); Of course, the comment would need to be adjusted.