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

    <tr>
        <th>Summary</th>
        <td>
            [clang]  no_unique_address working with tail padding of other member field.
        </td>
    </tr>

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

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

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

<pre>
    There is a different behavior with following code snipper using clang, GCC
```
#include <iostream>
#include <cstdint>
#include <type_traits>


struct Test {
    [[no_unique_address]] int a_;
    [[no_unique_address]] char b_;
};

struct Data {
 [[no_unique_address]] Test t_;
    [[no_unique_address]] bool c_;
};

template <typename First, typename Second>
inline static bool fits_in_tail_padding = []() {
    struct _x {
 [[no_unique_address]] First first;
        [[no_unique_address]] Second second;
    };
    return sizeof(_x) == sizeof(First);
}();

int main() {
    std::cout << "sizeof " << sizeof(Test) << "\n";
    std::cout << "sizeof " << sizeof(Data) << "\n";
    std::cout << fits_in_tail_padding<Test, bool> << std::endl;
    
    return 0;
}
```
g++ 14.2 Output:
```
sizeof 8
sizeof 8
1
```
clang 18.1 output:
```
sizeof 8
sizeof 12
0
```

GCC merges the member field into the previous member one's tailing padding bytes, while clang doesn't. 
Is this difference allowed or not?  
Is this a UB or a bug?
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyklUGz2jYQxz-NuOyEkSUM-OBDsEOmpx6anhnZWmO1skSl9SOvn74jG3jwStOknWGwtZJ2__tbeaViNEeHWLJ8x_J6oUbqfSjbc5Ztt5v1ovH6tfzSY0AwERRo03UY0BE02KsX4wOcDfXQeWv92bgjtF4jRGdOJwwwxslklTsyUcHnqmK8ZvwjW_PLbx4KaVxrR43AZGV8pIBqYPLTs-k2kjaO_mGWXk94oKAMxbcVd_-RwtgSfMFIwDa72QgAMAHYOX8YnfljxIPSOmCMLK9ZXoNxB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