microsoft / microsoft/STL

`<memory>`: noexcept strengthen `out_ptr` factory as well

Open
#5,446 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

decision needed enhancement
Dominant language
C++
Stars
11.1k
Forks
1.7k
Avg merge
4d 15h
Merged PRs (30d)
22

Description

The standard doesn't require the out_ptr_t c'tors to be noexcept:

explicit out_ptr_t(Smart& smart, Args... args);
[..]
[Note 2: The constructor is not noexcept to allow for a variety of non-terminating and safe implementation strategies. For example, an implementation can allocate a shared_ptr's internal node in the constructor and let implementation-defined exceptions escape safely. The destructor can then move the allocated control block in directly and avoid any other exceptions. — end note]

-- https://eel.is/c++draft/out.ptr.t#7

Due to its simplistic implementation, the STL decided to strengthen it: https://github.com/microsoft/STL/blob/b5df16a98934319e2e6864d6036cbe9cd9c74faf/stl/inc/memory#L4345-L4347

However, this has not been applied to the std::out_ptr factory: https://github.com/microsoft/STL/blob/b5df16a98934319e2e6864d6036cbe9cd9c74faf/stl/inc/memory#L4403-L4405

Has this simply been forgotten, or is there another reason?

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

Start in stl/inc/memory at the out_ptr_t constructor and std::out_ptr factory declarations linked in the issue. Compare their noexcept specifications with the cited standard wording and inspect existing out_ptr tests. Done means the reason for the differing specifications is established and the implementation or coverage reflects the decision.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.