Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ChuanqiXu9 opened this issue Nov 14, 2022 · 0 comments

Comments

@ChuanqiXu9
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant