Created on 2025-07-28.00:00:00 last changed 1 week ago
Proposed resolution (approved by CWG 2026-05-29):
Change in 9.8.1 [dcl.enum] paragraph 10 as follows:
Two enumeration types are layout-compatible enumerations if they have the same underlying type and the same values.
(From submission #732.)
Consider:
#include <iostream>
#include <type_traits>
enum E { E0 } e;
enum F { F0, F1, F2, F3 };
static_assert(std::is_same_v<std::underlying_type_t<E>, std::underlying_type_t<F>>); // assume this passes
struct A { E e; };
struct B { F f; };
union U {
A a;
B b;
} u;
bool test() {
return u.a.e == 2;
}
auto ptest = test;
int main() {
u.b.f = F2;
std::cout << ptest();
}
Both u.a and u.b are part of the common initial sequence, allowing u.a.e to read the value of u.a.f, even though E cannot represent all values of F.
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2026-05-30 05:56:01 | admin | set | status: open -> tentatively ready |
| 2025-11-06 23:04:52 | admin | set | messages: + msg8366 |
| 2025-07-28 00:00:00 | admin | create | |