| 1 |
// PR c++/95976 |
| 2 |
// { dg-do compile { target c++20 } } |
| 3 |
|
| 4 |
struct empty {}; |
| 5 |
|
| 6 |
union no_attribute_t |
| 7 |
{ |
| 8 |
empty _0; |
| 9 |
empty _1; |
| 10 |
}; |
| 11 |
|
| 12 |
union with_attribute_t |
| 13 |
{ |
| 14 |
[[no_unique_address]] empty _0; |
| 15 |
[[no_unique_address]] empty _1; |
| 16 |
}; |
| 17 |
|
| 18 |
constexpr no_attribute_t no_attribute{}; |
| 19 |
constexpr with_attribute_t with_attribute{}; |
| 20 |
|
| 21 |
// This succeeds |
| 22 |
static_assert( &no_attribute._0 == &no_attribute._1 ); |
| 23 |
|
| 24 |
// This fails |
| 25 |
static_assert( &with_attribute._0 == &with_attribute._1 ); |