Skip to content

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

Open
@frederick-vs-ja

Description

@frederick-vs-ja

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions