microsoft / microsoft/STL

Suggestion: investigate noexcept specification for `allocator_traits::deallocate/destroy`

Open
#5,593 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

A lot of clear-related functions rely on allocator_traits::destroy/deallocate, and are marked as noexcept (either required by standard or strengethened). Examples are many and are not listed here (search ::deallocate and ::destroy in the library).

However:
allocator_traits is either _Default_allocator_traits or _Normal_allocator_traits.
https://github.com/microsoft/STL/blob/313964b78a8fd5a52e7965e13781f735bcce13c5/stl/inc/xmemory#L759-L760

But currently:
_Default_allocator_traits: deallocate is marked as noexcept; but destroy is not.
deallocate: made noexcept by https://github.com/microsoft/STL/pull/4977
https://github.com/microsoft/STL/blob/313964b78a8fd5a52e7965e13781f735bcce13c5/stl/inc/xmemory#L717
destroy: not noexcept.
https://github.com/microsoft/STL/blob/313964b78a8fd5a52e7965e13781f735bcce13c5/stl/inc/xmemory#L741

_Normal_allocator_traits: neither deallocate nor destroy are noexcept.
deallocate:
https://github.com/microsoft/STL/blob/313964b78a8fd5a52e7965e13781f735bcce13c5/stl/inc/xmemory#L610
destroy:
https://github.com/microsoft/STL/blob/313964b78a8fd5a52e7965e13781f735bcce13c5/stl/inc/xmemory#L628

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/xmemory at the _Default_allocator_traits and _Normal_allocator_traits definitions, especially the deallocate and destroy functions linked in the issue. Search the library for ::deallocate and ::destroy, compare their noexcept requirements, and determine the consistent specification needed for the affected functions.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
tooling
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 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.