On Thu, Dec 02, 2021 at 03:32:58PM -0500, Jason Merrill wrote: > > So IMHO we need the patch I've posted (with the testcases slightly adjusted > > not to do those extra copies afterwards for now), > > and try to deal with the lvalue-to-rvalue conversion of indeterminate later, > > and once done, perhaps in a copy of those testcases readd those extra copies > > afterwards and verify it is rejected. > > Makes sense, except: > > > + gcc_assert (end == 1 || end == 2); > > This seems to assert that the value representation of a bit-field can't span > more than two bytes, which is wrong for, say, > > struct A > { > int : 1; > unsigned __int128 c : 128; // value representation spans 17 bytes > };
Sure, for arbitrary bitfields yes. But, the patch only deals with unsigned char and std::byte TYPE_MAIN_VARIANT (DECL_BIT_FIELD_TYPE (fld)) bitfields (others don't have the type listed in the standard and so should error right away, which is done by keeping the mask bits uncleared). For PCC_BITFIELD_TYPE_MATTERS I think end must be 1 even, if a bit-field would cross the byte boundary, it would be allocated in the next byte. But !PCC_BITFIELD_TYPE_MATTERS targets can cross the boundary, but as it can't be more than BITS_PER_UNIT bits (oversized bitfields are with warning downsized to the underlying's type precision), it can occupy at most 2 bytes. Jakub