Title
Floating point classifications were inadvertently changed in P0175
Status
c++20
Section
[cmath.syn]
Submitter
Thomas Köppe

Created on 2018-01-23.00:00:00 last changed 37 months ago

Messages

Date: 2018-03-18.16:03:30

Proposed resolution:

This wording is relative to N4713.

  1. Modify [cmath.syn] as indicated:

    […]
    namespace std {
      […]
      // [c.math.fpclass], classification / comparison functions
      int fpclassify(float x);
      int fpclassify(double x);
      int fpclassify(long double x);
      boolint isfinite(float x);
      boolint isfinite(double x);
      boolint isfinite(long double x);
      boolint isinf(float x);
      boolint isinf(double x);
      boolint isinf(long double x);
      boolint isnan(float x);
      boolint isnan(double x);
      boolint isnan(long double x);
      boolint isnormal(float x);
      boolint isnormal(double x);
      boolint isnormal(long double x);
      boolint signbit(float x);
      boolint signbit(double x);
      boolint signbit(long double x);
      boolint isgreater(float x, float y);
      boolint isgreater(double x, double y);
      boolint isgreater(long double x, long double y);
      boolint isgreaterequal(float x, float y);
      boolint isgreaterequal(double x, double y);
      boolint isgreaterequal(long double x, long double y);
      boolint isless(float x, float y);
      boolint isless(double x, double y);
      boolint isless(long double x, long double y);
      boolint islessequal(float x, float y);
      boolint islessequal(double x, double y);
      boolint islessequal(long double x, long double y);
      boolint islessgreater(float x, float y);
      boolint islessgreater(double x, double y);
      boolint islessgreater(long double x, long double y);
      boolint isunordered(float x, float y);
      boolint isunordered(double x, double y);
      boolint isunordered(long double x, long double y);
      […]
    }
    
Date: 2018-03-17.00:00:00

[ 2018-3-17 Adopted in Jacksonville ]

Date: 2018-01-29.00:00:00

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

Date: 2018-01-23.20:49:31

The paper P0175 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 isinf, isfinite, signbit, etc. (but not fpclassify) used to be specified to return "bool" 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 "int" from C, but failed to notice that we had already specified those functions differently, so the return type was changed to "int".

To restore the intended specification, we should change the return types of all the is... and signbit classification functions back to bool. Alternatively, we could decide that the return type should actually be int, but that would be a larger discussion.

Proposed resolution for restoring the original wording: Replace return type "int" with return type "bool" and for all the classification/comparison functions after "// classification/comparison functions" in [cmath.syn] except the fpclassify functions.

Related previous issue was LWG 1327 and the corresponding NB comment US-136 resolution.

History
Date User Action Args
2021-02-25 10:48:01adminsetstatus: wp -> c++20
2018-03-18 16:03:30adminsetmessages: + msg9755
2018-03-18 16:03:30adminsetstatus: voting -> wp
2018-02-12 01:13:49adminsetstatus: ready -> voting
2018-01-30 19:37:43adminsetmessages: + msg9666
2018-01-30 19:37:43adminsetstatus: new -> ready
2018-01-23 20:47:23adminsetmessages: + msg9624
2018-01-23 00:00:00admincreate