<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 2522: [fund.ts.v2] Contradiction in set_default_resource specification</title>
<meta property="og:title" content="Issue 2522: [fund.ts.v2] Contradiction in set_default_resource specification">
<meta property="og:description" content="C++ library issue. Status: TS">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue2522.html">
<meta property="og:type" content="website">
<meta property="og:image" content="http://cplusplus.github.io/LWG/images/cpp_logo.png">
<meta property="og:image:alt" content="C++ logo">
<style>
  p {text-align:justify}
  li {text-align:justify}
  pre code.backtick::before { content: "`" }
  pre code.backtick::after { content: "`" }
  blockquote.note
  {
    background-color:#E0E0E0;
    padding-left: 15px;
    padding-right: 15px;
    padding-top: 1px;
    padding-bottom: 1px;
  }
  ins {background-color:#A0FFA0}
  del {background-color:#FFA0A0}
  table.issues-index { border: 1px solid; border-collapse: collapse; }
  table.issues-index th { text-align: center; padding: 4px; border: 1px solid; }
  table.issues-index td { padding: 4px; border: 1px solid; }
  table.issues-index td:nth-child(1) { text-align: right; }
  table.issues-index td:nth-child(2) { text-align: left; }
  table.issues-index td:nth-child(3) { text-align: left; }
  table.issues-index td:nth-child(4) { text-align: left; }
  table.issues-index td:nth-child(5) { text-align: center; }
  table.issues-index td:nth-child(6) { text-align: center; }
  table.issues-index td:nth-child(7) { text-align: left; }
  table.issues-index td:nth-child(5) span.no-pr { color: red; }
  @media (prefers-color-scheme: dark) {
     html {
        color: #ddd;
        background-color: black;
     }
     ins {
        background-color: #225522
     }
     del {
        background-color: #662222
     }
     a {
        color: #6af
     }
     a:visited {
        color: #6af
     }
     blockquote.note
     {
        background-color: rgba(255, 255, 255, .10)
     }
  }
</style>
</head>
<body>
<hr>
<p><em>This page is a snapshot from the LWG issues list, see the <a href="lwg-active.html">Library Active Issues List</a> for more information and the meaning of <a href="lwg-active.html#TS">TS</a> status.</em></p>
<h3 id="2522"><a href="lwg-defects.html#2522">2522</a>. [fund.ts.v2] Contradiction in <code>set_default_resource</code> specification</h3>
<p><b>Section:</b> 8.8 <a href="https://cplusplus.github.io/fundamentals-ts/v2.html#memory.resource.global">[fund.ts.v2::memory.resource.global]</a> <b>Status:</b> <a href="lwg-active.html#TS">TS</a>
 <b>Submitter:</b> Tim Song <b>Opened:</b> 2015-07-28 <b>Last modified:</b> 2017-07-30</p>
<p><b>Priority: </b>2
</p>
<p><b>View all issues with</b> <a href="lwg-status.html#TS">TS</a> status.</p>
<p><b>Discussion:</b></p>
<p><b>Addresses: fund.ts.v2</b></p>
<p>
[memory.resource.global]/p7-8 says that the effects of <code>set_default_resource(r)</code> are
</p>
<blockquote><p>
If <code>r</code> is non-null, sets the value of the default memory resource pointer to <code>r</code>, otherwise sets the default memory 
resource pointer to <code>new_delete_resource()</code>.
</p></blockquote>
<p>
and the operation has the postcondition 
</p>
<blockquote><p>
<code>get_default_resource() == r</code>.
</p></blockquote>
<p>
When <code>r</code> is null, however, the postcondition cannot be met, since the call sets the default memory resource pointer to 
<code>new_delete_resource()</code>, and so <code>get_default_resource()</code> would return the value of <code>new_delete_resource()</code>, which 
is obviously not null and so cannot compare equal to <code>r</code>.
</p>

<strong>Previous resolution from Tim Song [SUPERSEDED]:</strong>
<blockquote class = "note">
<p>
This wording is relative to <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4480.html">N4480</a>.
</p>

<ol>
<li><p>Edit [memory.resource.global]/p8 as follows:</p>
<blockquote>
<pre>
<em>-6-</em> memory_resource* set_default_resource(memory_resource* r) noexcept;
</pre>
<blockquote>
<p>
-7- <i>Effects</i>: If <code>r</code> is non-null, sets the value of the default memory resource pointer to <code>r</code>, 
otherwise sets the default memory resource pointer to <code>new_delete_resource()</code>. 
<p/>
-8- <i>Postconditions</i>: <code>get_default_resource() == r</code> <ins>if <code>r</code> is non-null; otherwise, 
<code>get_default_resource() == new_delete_resource()</code></ins>. 
<p/>
[&hellip;]
</p>
</blockquote>
</blockquote>
</li>
</ol>
</blockquote>

<p><i>[2015-09-15 Geoffrey Romer comments and suggests alternative wording]</i></p>

<p>
 Let's just strike 8.8 <a href="https://cplusplus.github.io/fundamentals-ts/v2.html#memory.resource.global">[fund.ts.v2::memory.resource.global]</a>/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.
</p>

<p><i>[2015-10, Kona Saturday afternoon]</i></p>

<p>Move to Tentatively ready</p>

<p><i>[2015-10-26]</i></p>

<p>Daniel adjusts wording to lib. fund. v2.</p>


<p id="res-2522"><b>Proposed resolution:</b></p>
<p>
This wording is relative to <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4529.html">N4529</a>.
</p>

<ol>
<li><p>Edit [memory.resource.global]/p8 as follows:</p>
<blockquote>
<pre>
<em>-6-</em> memory_resource* set_default_resource(memory_resource* r) noexcept;
</pre>
<blockquote>
<p>
-7- <i>Effects</i>: If <code>r</code> is non-null, sets the value of the default memory resource pointer to <code>r</code>, 
otherwise sets the default memory resource pointer to <code>new_delete_resource()</code>. 
<p/>
<del>-8- <i>Postconditions</i>: <code>get_default_resource() == r</code>.</del>
<p/>
[&hellip;]
</p>
</blockquote>
</blockquote>
</li>
</ol>





</body>
</html>
