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

    <tr>
        <th>Summary</th>
        <td>
            __builtin_object_size(..., 1) of a struct member acts like __bos(..., 0)
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

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

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

<pre>
    ```
#include <stdint.h>
#include <stddef.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>

struct inside {
    int foo;
 int bar;
};

struct wat {
    struct inside array[20];
 int cow;
};

#define report(x)   printf(#x ": %zu\n", x)

struct wat *thing(void)
{
    struct wat *pool;
    struct wat local;
    struct inside *item;
    int j;

    pool = &local;
    item = pool->array;

    j = 4;

 report(sizeof(*item)); // should be 0x8
 report(__builtin_dynamic_object_size(pool, 0)); // should be 0x164
 report(__builtin_dynamic_object_size(pool, 1)); // should be 0x164
 report(__builtin_dynamic_object_size(item, 0)); // should be 0x164
 report(__builtin_dynamic_object_size(item, 1)); // should be 0x160 <- Clang says 0x164
    report(__builtin_dynamic_object_size(item + j, 1)); // should be 0x132

    return pool;
}
```

For `__builtin_dynamic_object_size(item, 1)` Clang reports 0x164. GCC correctly reports 0x160.

See https://godbolt.org/z/Gb5hMsrdT

Noticed while debugging https://github.com/ClangBuiltLinux/linux/issues/1780
cc @nickdesaulniers @nathanchance @isanbard 
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0VU2T4jYQ_TXNpWtcQsLGHHwYYNlLkktyp_SFrRkhUZK8M8yvT8nAgtldkk1lq4w_-nW_7vdkGR6jaZ3WDZRLKNcT3qfOh-ZV6zgRXh0bqMj5IGsgz0CZcdL2SiOwVUzKuFR0wD79AFZ69wAOxrWPqq0Rj2Djb9HhHFPoZULjoslp8-UpjIhoXMKd98AusRwQPHwNwHx9vb9le-NpTDXuwkPgRyiXlEC5HtNL__aAHihTemecxqAPPiSg9TvQBSIegnFpB7QGyt4RKAX2jEDLjx7KlcvPdIU590fT0ufUGdcCrb94o66J31Fxzj94b6_Dj2HrJf8uePGZPpuk96OMLP_lTnCO5z4IbI1Aq295M82A5rQnYJ9O5n5L8zJkze6Rr0ZG86H9ycHTbHSRD7ZEoBugG4yd761CoZG81_fV263ojU3GbdXR8b2RWy9etEzbTAu0HsyiKyQPaafV7L8ST_9v4pMHv2DiC_E_TUzypn3CleWuxciPcdQO8ec6ItAlvvyLvozevzlBpz44HL3veW-ebu4-d8N54wNCRX7KiYqcpZ5kndUW-Hm1QulD0DLZ4wgkxW3PP7XGLqVDBPZ80tV6JbxNhQ8t0M0H0M1nUXa_x6D-ui38wycjtcK3zliNSou-bY1r78lM6npRSL8HuhkGXWZtvxnXvwPd2PPVxNjrCHQznddnS6REmBFn5KvSkffWGR3iEOKp407mn87PJnIneFA4UQ1TC7bgE91MqzldVNV8Wk66Rs5qSmc1FUqTRVkyRthUTAmb8bmaiVJMTEMJZWRKKkLKmpUF1UoKRaWYzrWs9BxmRO-5sYW1X_bZmckwcVMu6pJMLBfaxstfW2hy0pPo2wgzYk1M8VqWTLK6ua7weGWLorgsLPod8svnb6_3QgfkMkW05lXjdit8vBbkzTbpg20emJ9HOF-eDsHntrfGD0r-DgAA__-6WUQA">