This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of TS status.

2522. [fund.ts.v2] Contradiction in set_default_resource specification

Section: 8.8 [fund.ts.v2::memory.resource.global] Status: TS Submitter: Tim Song Opened: 2015-07-28 Last modified: 2017-07-30

Priority: 2

View all issues with TS status.

Discussion:

Addresses: fund.ts.v2

[memory.resource.global]/p7-8 says that the effects of set_default_resource(r) are

If r is non-null, sets the value of the default memory resource pointer to r, otherwise sets the default memory resource pointer to new_delete_resource().

and the operation has the postcondition

get_default_resource() == r.

When r is null, however, the postcondition cannot be met, since the call sets the default memory resource pointer to new_delete_resource(), and so get_default_resource() would return the value of new_delete_resource(), which is obviously not null and so cannot compare equal to r.

Previous resolution from Tim Song [SUPERSEDED]:

This wording is relative to N4480.

  1. Edit [memory.resource.global]/p8 as follows:

    -6- memory_resource* set_default_resource(memory_resource* r) noexcept;
    

    -7- Effects: If r is non-null, sets the value of the default memory resource pointer to r, otherwise sets the default memory resource pointer to new_delete_resource().

    -8- Postconditions: get_default_resource() == r if r is non-null; otherwise, get_default_resource() == new_delete_resource().

    […]

[2015-09-15 Geoffrey Romer comments and suggests alternative wording]

Let's just strike 8.8 [fund.ts.v2::memory.resource.global]/p8. The problem is that p8 is restating p7 incorrectly, but the solution is not to restate p7 correctly, it's to stop trying to restate p7 at all.

[2015-10, Kona Saturday afternoon]

Move to Tentatively ready

[2015-10-26]

Daniel adjusts wording to lib. fund. v2.

Proposed resolution:

This wording is relative to N4529.

  1. Edit [memory.resource.global]/p8 as follows:

    -6- memory_resource* set_default_resource(memory_resource* r) noexcept;
    

    -7- Effects: If r is non-null, sets the value of the default memory resource pointer to r, otherwise sets the default memory resource pointer to new_delete_resource().

    -8- Postconditions: get_default_resource() == r.

    […]