https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112878

--- Comment #3 from Indu Bhagat <ibhagat at gcc dot gnu.org> ---
The limit of 255 is somewhat arbitrary but we need to follow it for now,
because libctf has a check in ctf_add_slice () in libctf/ctf-create.c :

  if ((ep->cte_bits > 255) || (ep->cte_offset > 255))
    return (ctf_set_typed_errno (fp, ECTF_SLICEOVERFLOW));
  ...
  slice.cts_bits = ep->cte_bits;
  slice.cts_offset = ep->cte_offset; 

The CTF generation in GCC does not have a mechanism to roll-back an already
added type.  In this testcase presented in the PR, we hit a representation
limit in CTF slices (for a member of a struct) and ICE, after the type for
struct (CTF_K_STRUCT) has already been added to the container.

To exit gracefully instead in GCC, one option is to simply check for both the
offset and size of the bitfield to be explicitly <= 255.  If the check fails,
we emit the member with type CTF_K_UNKNOWN instead.

Reply via email to