This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 114a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2024-05-04


2836. Conversion rank of long double and extended floating-point types

Section: 6.8.6  [conv.rank]     Status: tentatively ready     Submitter: Joshua Cranmer     Date: 2023-11-20     Liaison: EWG

Consider:

  auto f(long double x, std::float64_t y) {
    return x + y;
  }

What is the return type of f?

Suppose an implementation uses the same size and semantics for all of double, long double, and std::float64_t. C23 prefers the IEEE interchange type (i.e. std::float64_t) over long double and double. In contrast, C++ chooses long double, which has a higher rank than double, but std::float64_t is specified to have the same rank as double.

This outcome conflicts with the documented goal of P1467 that C++ and C conversion rules be aligned.

Suggested resolution [SUPERSEDED]:

Change in 6.8.6 [conv.rank] bullet 2.5 as follows:

Additional notes (December, 2023)

The suggested resolution would make a conversion from std::float64_t to double not implicit, which is not desirable.

David Olsen, one of the authors of P1467, asserts that the deviation from C is intentional, and was discussed with the C floating-point study group.

Forwarding to EWG via paper issue 1699 to confirm that the deviation from C is intentional and thus an Annex C entry should be created.

EWG 2024-03-18

This issue should be closed as NAD.

Possible resolution [SUPERSEDED]:

Add a new paragraph in C.7.3 [diff.basic] as follows:

Affected subclause: 6.8.6 [conv.rank]
Change: Conversion rank of same-sized long double vs. std::float64_t
Rationale: Provide implicit conversion from std::float64_t to double.
Effect on original feature: Change of semantically well-defined feature.
Difficulty of converting: Trivial: explicitly convert to the desired type.
How widely used: Rarely.

CWG 2024-04-19

The name std::float64_t is not valid C. CWG resolved to adding a note to 6.8.6 [conv.rank] bullet 2.5 instead.

Proposed resolution (approved by CWG 2024-05-03):

Change in 6.8.6 [conv.rank] bullet 2.5 as follows: