cplusplus / cplusplus/draft

[new.delete.single]/11 is confusingly subordinate to a clause in /10

Open
#7,912 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

P3-Other
Dominant language
TeX
Stars
221
Forks
813
Avg merge
16h 4m
Merged PRs (30d)
36

Description

Relevant wording:

void operator delete(void* ptr) noexcept;
void operator delete(void* ptr, std::size_t size) noexcept;
void operator delete(void* ptr, std::align_val_t alignment) noexcept;
void operator delete(void* ptr, std::size_t size, std::align_val_t alignment) noexcept;

10 # Preconditions: ptr is a null pointer or its value represents the address of a block of memory allocated by an earlier call to a (possibly replaced) operator new(std​::​size_t) or operator new(std​::​size_t, std​::​align_val_t) which has not been invalidated by an intervening call to operator delete.
11 # If the alignment parameter is not present, ptr was returned by an allocation function without an alignment parameter. If present, the alignment argument is equal to the alignment argument passed to the allocation function that returned ptr. If present, the size argument is equal to the size argument passed to the allocation function that returned ptr.

Note that the intended reading here is that all of /11 is within the scope of the second case in the "or" in /10, rather than being an additional set of preconditions independent of /10. This wording would benefit from being rephrased to make this clearer.

Note also that the "which has not been invalidated by an intervening call to operator delete" is redundant: this is already specified in [basic.compound]/4: "If a pointer value P is used in an evaluation E and P is not valid in the context of E, then the behavior is undefined if E is [...] an invocation of a deallocation function ([basic.stc.dynamic.deallocation])".

Contributor guide

No contributing guide indexed for this repository

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 source/support.tex around lines 2541 and 2553, and compare [new.delete.single]/10 with /11. Review how the “or” clause scopes the later requirements and check the cited basic.compound wording. Done means the text clearly expresses the intended scope and avoids the redundant invalidation wording.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, tex
Domain
documentation
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.