<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/87227>87227</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            ICE due to new bitfield algorithm (PR65742)
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
            urnathan
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          urnathan
      </td>
    </tr>
</table>

<pre>
    Sadly, PR65742 (commit 49839f97d295) introduced a bug for a corner case of vbase placement:
```
struct __attribute__((aligned(4))) Empty {} empty;

struct Char { char a; } cbase;

struct D : virtual Char {
  [[no_unique_address]] Empty e0;
  [[no_unique_address]] Empty e1;
  unsigned a : 24; // keep as 24bits
} d;
```

in the complete D, the Char vbase is placed 3 bytes after the vptr (i.e. at offset 7 or 11), so the bitfield must remain 24-bits.  We need dsize to limit the bitfield expansion, not nvsize.  They're nearly always the same, except for cases like this involving multiple zero-sized members (or bases).

I will shortly be posting a patch to address this. (FWIW, I don't expect the triggering cases to be at all common).
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMVMGOozgQ_RrnUmoEBgIcOHQ6E6lvq92V-hgZXIB3jM3aRXoyX78qwvZ0S3tYCSXYqffyXr1SqRjN6BBbUZ6ElGtwiiblhJSiPB_USpMP7b-3h87re_uH0vYu5Av89vuxrAoJQta9n2dDUDR13gxNpWVTCtmAcRS8XnvUoKBbRxh8AAW9Dw4D9Coi-AFuHb8sVvU4oyORP4v0LNJncUz3ZztGCmtPcL0qomC6lfB6FbIWslaWPWgh60LI5vHAt3mhO4jqJKozIB9EftqJP_O9TCpwGfT8okR-Akb0LOq_EWcQ-TPcTKBV2Q_8owSAG1menL-uzvy94lVpHTBGUZ5Fed5VYfrB_D8B2SfA6rbMuKcsRBabZnkR8gLfERdQEWTRGYq7-OoM-peVr119fBoHNCH0fl4sEsKZ8-Wbzd0jIBMfGWnIobsTRlADYdjKbgsFngOTYAKKwA9DRIIKfIAs2xJ5gei32s7QYNBqmNdIEHBWxoEsnlhwAvCG4BA16Gh-IpAHa3i0viDxx6JcNN4xrfME7sbVCcCfE96FrAKTqGDvoOy7uscNHtWMDMAfPS60zSKPYARrviPQZCIYd_P2ZtwI82rJLBbhJwb_xOwaZpw7DJGN-gDclChkk3xu5Cu8G2shTj6QvUOHsPhITKhgUdRP7GhPePvLhNkub69vrOwVNHuqiB1i_3BNwYwjBuZ4yCXPvIpAWcuRzYxpkoNuc93kjTpgm1VZ1lTpUcrD1Ja6q9MhG5oCm7Iuj1LXqm7KLO2rusx1eTCtTGWRFmmWZTLPy6QusJZY5EPRHzFNC1GkHJNNrL3NiQ_jwcS4YltXUlYHqzq0cd8gDt9h-3FfIaFlzFO3jlEUqTWR4i8WMmSxfX35Bnrdsmb0R8rKjj4YmmZu0b5shGwOa7DtRLRE3hTb2I-GprVLej8LeWH2_etpCf4v7EnIy6YpCnnZNP8TAAD__-OWjgA">