Skip to content

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

Open
@zygoloid

Description

@zygoloid

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])".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions