Title
Conversion rank of long double and extended floating-point types
Status
tentatively ready
Section
6.8.6 [conv.rank]
Submitter
Joshua Cranmer

Created on 2023-11-20.00:00:00 last changed 1 month ago

Messages

Date: 2024-05-04.21:20:44

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

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

  • ...
  • An extended floating-point type with the same set of values as more than one cv-unqualified standard floating-point type has a rank equal to the rank of double. [ Note: The treatment of std::float64_t differs from that of the analoguous _Float64 in C on platforms where all of long double, double, and std::float64_t have the same set of values (see ISO/IEC 9899:2024 H.4.2). -- end note ]
Date: 2024-05-04.21:20:44

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.

Date: 2023-12-15.00:00:00

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.
Date: 2024-04-19.21:17:21

Suggested resolution [SUPERSEDED]:

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

  • ...
  • An extended floating-point type with the same set of values as more than one cv-unqualified standard floating-point type has a rank equal to the highest rank of double among such types.
Date: 2023-11-20.00:00:00

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.

History
Date User Action Args
2024-05-04 21:20:44adminsetmessages: + msg7687
2024-05-04 21:20:44adminsetstatus: review -> tentatively ready
2024-04-19 21:17:21adminsetmessages: + msg7669
2024-03-18 12:50:42adminsetstatus: open -> review
2023-12-03 22:09:25adminsetmessages: + msg7549
2023-12-03 15:08:26adminsetmessages: + msg7546
2023-11-20 00:00:00admincreate