On 12/2/21 15:56, Jakub Jelinek wrote:
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).
Ah, of course. The patch is OK, though you might factor
+ else if (is_byte_access_type (type)
+ && TYPE_MAIN_VARIANT (type) != char_type_node)
into is_byte_access_type_not_plain_char. OK either way.
Jason