[out.ptr.t][inout.ptr.t] Get rid of TBAA-violating implication #8740
+2
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
On many platforms, we can just reuse the object/value representation of the raw pointer stored within
(in)out_ptr_tforoperator void**. However, directly use ofreinterpret_castviolates the strict aliasing rule ([basic.lval]/11). At the time whenout_ptr_tandinout_ptr_twere 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_aswas added later, making it possible to reuse value representation without UB. This PR usesstart_lifetime_asin the notes, and thus makes them probably applicable for implementations that have compatible representations forT*andvoid*.Note that
start_lifetime_ascan cause conflicts on object creation, but conflicts are already allowed in [out.ptr.t]/5 and [inout.ptr.t]/5.