microsoft / microsoft/STL

`<memory>`: Potential ABI issue on `constexpr`-compatibility of `(in)out_ptr_t`

Open
#5,368 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
C++
Stars
11.2k
Forks
1.7k
Avg merge
4d 15h
Merged PRs (30d)
22

Description

WG21-P3037R4 "constexpr std::shared_ptr" has been recently forwarded to LWG for C++26. The paper currently also makes (in)out_ptr_t constexpr, including their operator void**() conversion functions.

It seems that the non-trivial changes, probably including changing the type of some data members, are necessary for constexpr-compatibility (e.g. avoiding UB, reinterpret_cast, and bit_cast involving pointers). Before C++23 ABI freeze of MSVC STL, we might need to determine and switch to use a suitable implementation strategy for (in)out_ptr_t to avoid undesired ABI breakage.

IMO we might need to switch to use union to store raw pointers (along with void* when necessary), while using std::is_within_lifetime to detect the active member during constant evaluation (although the compiler support from MSVC is not yet available now).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No files, tests, or entry points are named. Start by reading WG21-P3037R4 and the current (in)out_ptr_t implementation, then assess the constexpr requirements and ABI impact described in the issue. Done means selecting and implementing an ABI-safe strategy, with appropriate validation for constexpr compatibility.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.