http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58970
--- Comment #23 from Bernd Edlinger <bernd.edlinger at hotmail dot de> ---
hmm...
all examples I can see, where bitpos is negative,
or less than the representative's bitoffset with offset=NULL,
are just blandtly invalid.
The only valid example would be
struct S { unsigned char s : 1; };
void function(struct S *p)
{
p[-1].s = 0;
}
However this one is gimplified to
D.1590 = p + -1;
D.1590->s = 0;
no ARRAY_REFs at all, never.
Handling all that negative bitoffsets seems to be
a bit too much complication just to generate
valid code for invalid C.
At least returning negative bitoffset could be easily
avoided in get_inner_reference:
--- expr.c.jj 2013-10-31 14:57:05.000000000 +0100
+++ expr.c 2013-11-05 09:24:39.821624212 +0100
@@ -6708,7 +6708,7 @@
tem = tem.sext (TYPE_PRECISION (sizetype));
tem = tem.lshift (BITS_PER_UNIT == 8 ? 3 : exact_log2 (BITS_PER_UNIT));
tem += bit_offset;
- if (tem.fits_shwi ())
+ if (tem.fits_shwi () && !tem.is_negative ())
{
*pbitpos = tem.to_shwi ();
*poffset = offset = NULL_TREE;