cplusplus / cplusplus/draft

[basic.stc.dynamic.general]p2 is not easy to tell whether the following functions are attached to the global mdoule fragment

Open
#5,949 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

The [basic.stc.dynamic.general]p2 tells

The library provides default definitions for the global allocation and
deallocation functions. Some global allocation and deallocation
functions are replaceable\iref{new.delete};
these are attached to the global module\iref{module.unit}.
A \Cpp{} program shall
provide at most one definition of a replaceable allocation or
deallocation function. Any such function definition replaces the default
version provided in the library\iref{replacement.functions}. The
following allocation and deallocation functions\iref{support.dynamic}
are implicitly declared in global scope in each translation unit of a
program.

[[nodiscard]] void* operator new(std::size_t);
[[nodiscard]] void* operator new(std::size_t, std::align_val_t);

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

[[nodiscard]] void* operator new[](std::size_t);
[[nodiscard]] void* operator new[](std::size_t, std::align_val_t);

void operator delete[](void*) noexcept;
void operator delete[](void*, std::size_t) noexcept;
void operator delete[](void*, std::align_val_t) noexcept;
void operator delete[](void*, std::size_t, std::align_val_t) noexcept;

My confusion is that:

  • Some global allocation and deallocation
    functions are replaceable\iref{new.delete};
    these are attached to the global module\iref{module.unit}.
  • The
    following allocation and deallocation functions\iref{support.dynamic}
    are implicitly declared in global scope in each translation unit of a
    program.

But from the paragraph itself we can't tell if the following allocation and deallocation functions are the replaceable functions or not. So that we can't make sure the following allocation and deallocation functions should be attached to the global module fragment or not from the wording. Although later I checked http://eel.is/c++draft/new.delete carefully to make sure that all of these functions should be attached to the global module fragment, I still feel like the paragraph is hard to read.

I suggest to add a replaceable to the last sentence to make it as:

The
following replaceable allocation and deallocation functions\iref{support.dynamic}
are implicitly declared in global scope in each translation unit of a
program.

So that it would be pretty clear these functions should be attached to the global module fragment at the first sight.

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 the [basic.stc.dynamic.general] paragraph 2 wording quoted in the issue and compare it with the referenced new.delete and module.unit sections. Clarify whether the listed functions are replaceable by adding the proposed wording, then verify that the resulting text consistently describes their attachment to the global module fragment.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.