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

    <tr>
        <th>Summary</th>
        <td>
            Clang and GCC disagree on whether lambda closure type is "POD for the purpose of layout"
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang:frontend
      </td>
    </tr>

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

    <tr>
      <th>Reporter</th>
      <td>
          hubert-reinterpretcast
      </td>
    </tr>
</table>

<pre>
    Similar to #46056, Clang and GCC disagree on "POD for the purpose of layout": in this case, on closure types.

It appears that, in the case below, GCC considers the first closure type to be "POD for the purpose of layout" and does not allocate additional subobjects of the derived class into the tail padding. Clang does allocate into the tail padding, resulting in a smaller size of 8 for the derived class instead of 12.

https://godbolt.org/z/4T8f1sbMr

### SOURCE (`<stdin>`):
```cpp
template <typename ...T>
struct Callables : T ... {
  Callables(T ...t) : T(t) ... {}
  using T::operator() ...;
};

inline auto f(int x, char y) {
  Callables callables([x, y](void) {}, [y](int) {});
  static_assert(sizeof(callables) == 12);
  return callables;
}

int main(void) { f(0, 1)(42); }
```

### COMPILER INVOCATION:
```
clang++ --target=x86_64-unknown-linux-gnu -xc++ -fsyntax-only -
```

### ACTUAL OUTPUT:
```
<stdin>:9:3: error: static assertion failed due to requirement 'sizeof (callables) == 12'
  static_assert(sizeof(callables) == 12);
  ^             ~~~~~~~~~~~~~~~~~~~~~~~
<stdin>:9:35: note: expression evaluates to '8 == 12'
  static_assert(sizeof(callables) == 12);
                ~~~~~~~~~~~~~~~~~~^~~~~
1 error generated.
```

### EXPECTED OUTPUT:
Clean compile.

### COMPILER VERSION INFO (`clang++ -v`):
```
clang version 16.0.0 (https://github.com/llvm/llvm-project.git a72d8d704178118b254d9ff84a78afb18813b888)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/wandbox/clang-head/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10
Candidate multilib: .;@m64
Selected multilib: .;@m64
```

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJytVltv4jgU_jXhxSLKDWIeeKABVpVmhqqlo3kbObED3jVx1nZamF-_5zjQQred7UpUKeD4XL5zP6Xmh-mD3EnFDHGaBEmajaPROEgKUijWbAhrOPmjKAiXlm2MEEQ3QJXcreak1sCzFaTtTKst3NREsYPuHNwH6YzIBq6lJRWzAgUCZ6W07Ywg7tAKGwbRPIhm_eetI6xtBTMWmJhDes8vPDsphdLP-BKxVLqxkgtPKkgtjXUXktGSUnwGpjePa2FJowGAUrpiThDGuXRSN0wR25W6_FNUziIjygHF8klw0MisBZCgDF87JhVpkbPZhEfneckvUt8lRZuMsJ1ycECTGbE7YBGGWPnLo6UvJrxVbZ1gHEni5MKZW-daCyEIkiU8G81LrVyoDWhb_oL_bE3r2JZfzTkTxL5_yMPq8b5YgP9oMI6CtLAOkAbpAk_JBOX2DHD0T9W2_Rsndq1CU4EJA9GwnSBhGK6R2VNYZ7rKkQIsZKUC72CirJGGBPlNT0NerwGCv4RYTXpSeOMPJ458fmLqLHpwjfDSmW6FYU4btKGnDtKjeGR5-e0_ZaNkA1HvID41cECgyB4DU22hLA5e9zvgIDNfYQajG89yCEZzOD5pyU98oA8ugOB4B-LPryYvaAixjjlZ_YToCgNEFFNAI6QzVegIsGAOQb9kNsJ1pjlDdW7xhbmO7BhE9AKmtzxCpDGKTWh2FE9e2U8Bfz9titXXu9svi3ty--37qpitb1ff_p0r_bHC8giSG3jIcOiY2QgHJu3p-Oc4G3bNX41-boYQlW4_3DQdGe6rE3VtD41j-6Fu1IEMPwVsVqwfZ1_I6nF997j-CNJ5nqczzPIUE04YA1kEP_rQkD400BtIDVUMtcg732-M-LuTRuwEODdI8j5w5DeRy68S82C0IOd_Qb64wvORQ0boCOiUw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