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

    <tr>
        <th>Summary</th>
        <td>
            __builtin_object_size() does not track object sizes across asignment
        </td>
    </tr>

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

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

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

<pre>
    The information used to examine object sizes is lost across assignment:

```
struct something {
    int a;
    int c[4];
    int b;
};

unsigned char *p = &instance->c[1];
```

`__builtin_object_size(p, 1)` should equal 12, but instead is -1. (`__bos(&instance->c[1], 1)` correctly returns 12.)

This breaks `FORTIFY_SOURCE` protection as buffers that should be visible become trivially obfuscated, and is a regression compared to GCC.

https://godbolt.org/z/4Pozfe9bY
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx1U01zmzAQ_TXiogmDBdjmwCFx4k5P6aTpISfPChajWpZcfaRNfn1XOHFcd8IIsauV3j7tPqTtX9rHEbkyg3V7CMoaHj32PFiOf2CvDHIrf2IXuFev6LnyXFsfOHTOes_Be7U1ezSBldesuGXF-zwv3sbk-uBiwrB7DKMyW84WN8cIp0cZAmTlxUrH6puK1bf_BeRphS0-osc5mkSILtCN4DgT1wfOylsy5sr4AKbDK1beJejZOfQF3dPiZiOj0kGZzbEKm1QFJpYHJlZ8xkRDe7gfbdQ9x18RNJ-JFJIx8JQQoU8lu5rlRGF5BLQ-mZ8QOoPtrHOUUr9whyE64wk7T7Ezio8joUuHsPOczqzvHx6_rp823-9_PKzuEsjB2UAgqa9AO-MwoPM8jBDeaUvkz8orqZHMjhrEg1PPCjQltnKIvoOAfSIGZroMEJ-tQ-o8gdKBA7ijYL6sVvk5uTGEg0-6EGsaW9tLq0Nu3Za8V3qrb_Z1wEY-ZX1b9k3ZQBZU0Nh-VnW6PO8tqdDYQCyh2_0rzpMo3zSZRafbCxYqjFHmRJscrZ_fP1dUqIRErvI-IvVoXdeLSmRjWwwgoFvOq2qoK9EsiqLGZll2XVcDlMU80yBR-5Z6yIQw-JtPEGRTRzPVikKIohYLmkuxzBdzUUHRDBLLGhrSS1XgHpTOE49Unsy1EyUZt56CWvngP4LHXw5xSkf4EMNoXbtD9NmUt514_wWlLDG_">