<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 3051: Floating point classifications were inadvertently changed in P0175</title>
<meta property="og:title" content="Issue 3051: Floating point classifications were inadvertently changed in P0175">
<meta property="og:description" content="C++ library issue. Status: C++20">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue3051.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="3051"><a href="lwg-defects.html#3051">3051</a>. Floating point classifications were inadvertently changed in P0175</h3>
<p><b>Section:</b> 29.7.1 <a href="https://wg21.link/cmath.syn">[cmath.syn]</a> <b>Status:</b> <a href="lwg-active.html#C++20">C++20</a>
 <b>Submitter:</b> Thomas K&ouml;ppe <b>Opened:</b> 2018-01-23 <b>Last modified:</b> 2021-02-25</p>
<p><b>Priority: </b>0
</p>
<p><b>View other</b> <a href="lwg-index-open.html#cmath.syn">active issues</a> in [cmath.syn].</p>
<p><b>View all other</b> <a href="lwg-index.html#cmath.syn">issues</a> in [cmath.syn].</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 paper <a href="https://wg21.link/p0175">P0175</a> was meant to be a purely editorial change to 
spell out the synopses of the "C library" headers. However it contained the following inadvertent 
normative change: The floating point classification functions <code>isinf</code>, <code>isfinite</code>, 
<code>signbit</code>, etc. (but not <code>fpclassify</code>) used to be specified to return "<code>bool</code>" 
in C++14. In C, those are macros, but in C++ they have always been functions. During the preparation 
of P0175, I recreated the function signatures copying the return type "<code>int</code>" from C, but 
failed to notice that we had already specified those functions differently, so the return type was 
changed to "<code>int</code>".
<p/>
To restore the intended specification, we should change the return types of all the <code>is...</code> 
and <code>signbit</code> classification functions back to <code>bool</code>. Alternatively, we could decide 
that the return type should actually be <code>int</code>, but that would be a larger discussion.
<p/>
Proposed resolution for restoring the original wording: Replace return type "<code>int</code>" with 
return type "<code>bool</code>" and for all the classification/comparison functions after 
"<i>// classification/comparison functions</i>" in [cmath.syn] <em>except</em> the <code>fpclassify</code> 
functions.
<p/>
Related previous issue was LWG <a href="lwg-defects.html#1327" title="templates defined in &lt;cmath&gt; replacing C macros with the same name (Status: Resolved)">1327</a><sup><a href="https://cplusplus.github.io/LWG/issue1327" title="Latest snapshot">(i)</a></sup> and the corresponding 
<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3141.pdf#page=188">NB comment US-136</a> 
resolution.
</p>

<p><i>[
2018-01-29 Moved to Tentatively Ready after 8 positive votes on c++std-lib.
]</i></p>

<p><i>[2018-3-17 Adopted in Jacksonville]</i></p>



<p id="res-3051"><b>Proposed resolution:</b></p>
<p>This wording is relative to <a href="https://wg21.link/n4713">N4713</a>.</p>

<ol>
<li><p>Modify 29.7.1 <a href="https://wg21.link/cmath.syn">[cmath.syn]</a> as indicated:</p>

<blockquote>
<pre>
[&hellip;]
namespace std {
  [&hellip;]
  <i>// 29.7.5 <a href="https://wg21.link/c.math.fpclass">[c.math.fpclass]</a>, classification / comparison functions</i>
  int fpclassify(float x);
  int fpclassify(double x);
  int fpclassify(long double x);
  <ins>bool</ins><del>int</del> isfinite(float x);
  <ins>bool</ins><del>int</del> isfinite(double x);
  <ins>bool</ins><del>int</del> isfinite(long double x);
  <ins>bool</ins><del>int</del> isinf(float x);
  <ins>bool</ins><del>int</del> isinf(double x);
  <ins>bool</ins><del>int</del> isinf(long double x);
  <ins>bool</ins><del>int</del> isnan(float x);
  <ins>bool</ins><del>int</del> isnan(double x);
  <ins>bool</ins><del>int</del> isnan(long double x);
  <ins>bool</ins><del>int</del> isnormal(float x);
  <ins>bool</ins><del>int</del> isnormal(double x);
  <ins>bool</ins><del>int</del> isnormal(long double x);
  <ins>bool</ins><del>int</del> signbit(float x);
  <ins>bool</ins><del>int</del> signbit(double x);
  <ins>bool</ins><del>int</del> signbit(long double x);
  <ins>bool</ins><del>int</del> isgreater(float x, float y);
  <ins>bool</ins><del>int</del> isgreater(double x, double y);
  <ins>bool</ins><del>int</del> isgreater(long double x, long double y);
  <ins>bool</ins><del>int</del> isgreaterequal(float x, float y);
  <ins>bool</ins><del>int</del> isgreaterequal(double x, double y);
  <ins>bool</ins><del>int</del> isgreaterequal(long double x, long double y);
  <ins>bool</ins><del>int</del> isless(float x, float y);
  <ins>bool</ins><del>int</del> isless(double x, double y);
  <ins>bool</ins><del>int</del> isless(long double x, long double y);
  <ins>bool</ins><del>int</del> islessequal(float x, float y);
  <ins>bool</ins><del>int</del> islessequal(double x, double y);
  <ins>bool</ins><del>int</del> islessequal(long double x, long double y);
  <ins>bool</ins><del>int</del> islessgreater(float x, float y);
  <ins>bool</ins><del>int</del> islessgreater(double x, double y);
  <ins>bool</ins><del>int</del> islessgreater(long double x, long double y);
  <ins>bool</ins><del>int</del> isunordered(float x, float y);
  <ins>bool</ins><del>int</del> isunordered(double x, double y);
  <ins>bool</ins><del>int</del> isunordered(long double x, long double y);
  [&hellip;]
}
</pre>
</blockquote>
</li>
</ol>




</body>
</html>
