This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 118f. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.
2025-11-07
(From submission #367.)
Consider:
struct S {
alignas(int) mutable unsigned char buf[sizeof(int)];
};
int f() {
const S s{};
::new ((void*)s.buf) int{42};
}
Creating a new object in the mutable portion of a const complete object is undefined behavior per 6.8.4 [basic.life] paragraph 12. However, this ought to be allowed.
Possible resolution:
Change in 6.8.4 [basic.life] paragraph 12 as follows:
Creating a new object O within the storage that a const, complete object X with static, thread, or automatic storage duration occupies, or within the storage that such a const object used to occupy before its lifetime ended, results in undefined behavior unless O is nested within a mutable subobject of X. [ Example: ... ]