[C++0x] contiguous bitfields race implementation
Jason Merrill
jason@redhat.com
Fri Jul 22 19:16:00 GMT 2011
On 07/18/2011 08:02 AM, Aldy Hernandez wrote:
> + /* If other threads can't see this value, no need to restrict stores. */
> + if (ALLOW_STORE_DATA_RACES
> + || !DECL_THREAD_VISIBLE_P (innerdecl))
> + {
> + *bitstart = *bitend = 0;
> + return;
> + }
What if get_inner_reference returns something that isn't a DECL, such as
an INDIRECT_REF?
> + if (fld)
> + {
> + /* We found the end of the bit field sequence. Include the
> + padding up to the next field and be done. */
> + *bitend = bitpos - 1;
> + }
bitpos is the position of "field", and it seems to me we want the
position of "fld" here.
> + /* If unset, no restriction. */
> + if (!bitregion_end)
> + maxbits = 0;
> + else
> + maxbits = (bitregion_end - bitregion_start) % align;
Maybe use MAX_FIXED_MODE_SIZE so you don't have to test it against 0?
> + if (!bitregion_end)
> + maxbits = 0;
> + else if (1||bitpos + offset * BITS_PER_UNIT < bitregion_start)
> + maxbits = bitregion_end - bitregion_start;
> + else
> + maxbits = bitregion_end - (bitpos + offset * BITS_PER_UNIT) + 1;
I assume the 1|| was there for debugging?
Surely bitpos+offset*BITS_PER_UNIT, which would be the bit position of
the bit-field, must be within [bitregion_start,bitregion_end)?
Jason
More information about the Gcc-patches
mailing list