<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 3154: Common and CommonReference have a common defect</title>
<meta property="og:title" content="Issue 3154: Common and CommonReference have a common defect">
<meta property="og:description" content="C++ library issue. Status: C++20">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue3154.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#C++20">C++20</a> status.</em></p>
<h3 id="3154"><a href="lwg-defects.html#3154">3154</a>. <code>Common</code> and <code>CommonReference</code> have a common defect</h3>
<p><b>Section:</b> 18.4.6 <a href="https://wg21.link/concept.common">[concept.common]</a> <b>Status:</b> <a href="lwg-active.html#C++20">C++20</a>
 <b>Submitter:</b> Casey Carter <b>Opened:</b> 2018-08-10 <b>Last modified:</b> 2021-02-25</p>
<p><b>Priority: </b>0
</p>
<p><b>View all other</b> <a href="lwg-index.html#concept.common">issues</a> in [concept.common].</p>
<p><b>View all issues with</b> <a href="lwg-status.html#C++20">C++20</a> status.</p>
<p><b>Discussion:</b></p>
<p>
The semantic requirements of both <code>Common</code>
(18.4.6 <a href="https://wg21.link/concept.common">[concept.common]</a>):
</p>
<blockquote>
<p>
-2- Let <code>C</code> be <code>common_­type_­t&lt;T, U&gt;</code>. Let <code>t</code> be a
function whose return type is <code>T</code>, and let <code>u</code> be a function whose
return type is <code>U</code>. <code>Common&lt;T, U&gt;</code> is satisfied only if:
</p><p>
(2.1) &mdash; <code>C(t())</code> equals <code>C(t())</code> if and only if <code>t()</code>
is an equality-preserving expression (18.2 <a href="https://wg21.link/concepts.equality">[concepts.equality]</a>).
</p><p>
(2.2) &mdash; <code>C(u())</code> equals <code>C(u())</code> if and only if <code>u()</code>
is an equality-preserving expression (18.2 <a href="https://wg21.link/concepts.equality">[concepts.equality]</a>).
</p>
</blockquote>
<p>
and similarly <code>CommonReference</code> ( [concept.commonreference]):
</p>
<blockquote>
<p>
-2- Let <code>C</code> be <code>common_­reference_­t&lt;T, U&gt;</code>. Let <code>t</code> be
a function whose return type is <code>T</code>, and let <code>u</code> be a function
whose return type is <code>U</code>. <code>CommonReference&lt;T, U&gt;</code> is
satisfied only if:
</p><p>
(2.1) &mdash; <code>C(t())</code> equals <code>C(t())</code> if and only if <code>t()</code>
is an equality-preserving expression (18.2 <a href="https://wg21.link/concepts.equality">[concepts.equality]</a>).
</p><p>
(2.2) &mdash; <code>C(u())</code> equals <code>C(u())</code> if and only if <code>u()</code>
is an equality-preserving expression.
</p>
</blockquote>
<p>
don't properly reflect the intended design that conversions to the common type /
common reference type are identity-preserving: in other words, that converting
two values to the common type produces equal results if and only if the values
were initially equal. The phrasing "<code>C(E)</code> equals <code>C(E)</code> if and only if <code>E</code> is an equality-preserving expression" is also clearly
defective regardless of the intended design: the assertion "<code>E</code> is not
equality-preserving" does not imply that every evaluation of <code>E</code> produces
different results.
</p>
<p><i>[2018-08 Batavia Monday issue prioritization]</i></p>

<p>Priority set to 0, status to 'Tentatively Ready'</p>
<p><i>[2018-11, Adopted in San Diego]</i></p>



<p id="res-3154"><b>Proposed resolution:</b></p>

<p>This wording is relative to <a href="https://wg21.link/n4762">N4762</a>.</p>

<ol>
<li><p>Modify 18.4.5 <a href="https://wg21.link/concept.commonref">[concept.commonref]</a> p2 as follows:</p>
<blockquote>
<p>
-2- Let <code>C</code> be <code>common_­reference_­t&lt;T, U&gt;</code>. Let <del><code>t</code>
be a function whose return type is</del> <ins><code>t1</code> and <code>t2</code> be
equality-preserving expressions (18.2 <a href="https://wg21.link/concepts.equality">[concepts.equality]</a>) such that
<code>decltype((t1))</code> and <code>decltype((t2))</code> are each</ins> <code>T</code>,
and let <del><code>u</code> be a function whose return type is</del> <ins><code>u1</code>
and <code>u2</code> be equality-preserving expressions such that
<code>decltype((u1))</code> and <code>decltype((u2))</code> are each</ins> <code>U</code>.
<ins><code>T</code> and <code>U</code> model</ins> <code>CommonReference&lt;T, U&gt;</code> <del>is satisfied</del> only if:
</p><p>
(2.1) &mdash; <code>C(t<ins>1</ins><del>()</del>)</code> equals
<code>C(t<ins>2</ins><del>()</del>)</code> if and only if
<code>t<ins>1</ins><del>()</del></code> <ins>equals <code>t2</code>, and</ins>
<del>is an equality-preserving expression (18.2 <a href="https://wg21.link/concepts.equality">[concepts.equality]</a>).</del>
</p><p>
(2.2) &mdash; <code>C(u<ins>1</ins><del>()</del>)</code> equals
<code>C(u<ins>2</ins><del>()</del>)</code> if and only if
<code>u<ins>1</ins><del>()</del></code> <ins>equals <code>u2</code></ins>
<del>is an equality-preserving expression</del>.
</p>
</blockquote>
</li>
<li><p>Modify 18.4.6 <a href="https://wg21.link/concept.common">[concept.common]</a> p2 similarly:</p>
<blockquote>
<p>
-2- Let <code>C</code> be <code>common_­type_­t&lt;T, U&gt;</code>. Let <del><code>t</code> be
a function whose return type is</del> <ins><code>t1</code> and <code>t2</code> be
equality-preserving expressions (18.2 <a href="https://wg21.link/concepts.equality">[concepts.equality]</a>) such that
<code>decltype((t1))</code> and <code>decltype((t2))</code> are each</ins> <code>T</code>,
and let <del><code>u</code> be a function whose return type is</del> <ins><code>u1</code>
and <code>u2</code> be equality-preserving expressions such that
<code>decltype((u1))</code> and <code>decltype((u2))</code> are each</ins> <code>U</code>.
<ins><code>T</code> and <code>U</code> model</ins> <code>Common&lt;T, U&gt;</code> <del>is
satisfied</del> only if:
</p><p>
(2.1) &mdash; <code>C(t<ins>1</ins><del>()</del>)</code> equals
<code>C(t<ins>2</ins><del>()</del>)</code> if and only if
<code>t<ins>1</ins><del>()</del></code> <ins>equals <code>t2</code>, and</ins>
<del>is an equality-preserving expression (18.2 <a href="https://wg21.link/concepts.equality">[concepts.equality]</a>).</del>
</p><p>
(2.2) &mdash; <code>C(u<ins>1</ins><del>()</del>)</code> equals
<code>C(u<ins>2</ins><del>()</del>)</code> if and only if
<code>u<ins>1</ins><del>()</del></code> <ins>equals <code>u2</code></ins>
<del>is an equality-preserving expression (18.2 <a href="https://wg21.link/concepts.equality">[concepts.equality]</a>)</del>.
</p>
</blockquote>
</li>
</ol>





</body>
</html>
