From 44c228d4a471a08a80ab73a75af2859171b4ce9e Mon Sep 17 00:00:00 2001 From: "A. Jiang" Date: Thu, 12 Feb 2026 15:02:36 +0800 Subject: [PATCH] [out.ptr.t][inout.ptr.t] Get rid of TBAA-violating implication On many platforms, we can just reuse the object/value representation of the raw pointer stored within `(in)out_ptr_t` for `operator void**`. However, directly use of `reinterpret_cast` violates the strict aliasing rule ([basic.lval]/11). At the time when `out_ptr_t` and `inout_ptr_t` were added to C++23, there was not yet any standard utility bypassing the strict aliasing rule, and thus the notes had to indicate core UB and were only applicable for implementations that didn't aggressively perform type-based aliasing analysis (TBAA). Luckily, `start_lifetime_as` was added later, making it possible to reuse value representation without UB. This PR uses `start_lifetime_as` in the notes, and thus makes them probably applicable for implementations that have compatible representations for `T*` and `void*`. Note that `start_lifetime_as` can cause conflicts on object creation, but conflicts are already allowed in [out.ptr.t]/5 and [inout.ptr.t]/5. --- source/memory.tex | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/memory.tex b/source/memory.tex index 4ab41e8b88..1ba4bdd1b4 100644 --- a/source/memory.tex +++ b/source/memory.tex @@ -5509,7 +5509,7 @@ \pnum \begin{note} -\tcode{reinterpret_cast(static_cast(*this))} +\tcode{start_lifetime_as(\&const_cast(p))} can be a viable implementation strategy for some implementations. \end{note} \end{itemdescr} @@ -5745,7 +5745,7 @@ \pnum \begin{note} -\tcode{reinterpret_cast(static_cast(*this))} +\tcode{start_lifetime_as(\&const_cast(p))} can be a viable implementation strategy for some implementations. \end{note} \end{itemdescr}