Title
Allow floating-point conversions in converted constant expressions
Status
drwp
Section
7.7 [expr.const]
Submitter
Brian Bi

Created on 2023-11-03.00:00:00 last changed 5 months ago

Messages

Date: 2024-02-16.23:23:05

Proposed resolution (approved by CWG 2024-02-16):

Change in 7.7 [expr.const] paragraph 12 as follows:

A converted constant expression of type T is an expression, implicitly converted to type T, where the converted expression is a constant expression and the implicit conversion sequence contains only
  • user-defined conversions,
  • lvalue-to-rvalue conversions (7.3.2 [conv.lval]),
  • array-to-pointer conversions (7.3.3 [conv.array]),
  • function-to-pointer conversions (7.3.4 [conv.func]),
  • qualification conversions (7.3.6 [conv.qual]),
  • integral promotions (7.3.7 [conv.prom]),
  • integral conversions (7.3.9 [conv.integral]) other than narrowing conversions (9.4.5 [dcl.init.list]),
  • floating-point promotions (7.3.8 [conv.fpprom]),
  • floating-point conversions (7.3.10 [conv.double]) where the source value can be represented exactly in the destination type,
  • null pointer conversions (7.3.12 [conv.ptr]) from std::nullptr_t,
  • null member pointer conversions (7.3.13 [conv.mem]) from std::nullptr_t, and
  • function pointer conversions (7.3.14 [conv.fctptr]),
and where the reference binding (if any) binds directly.
Date: 2024-03-15.00:00:00

[Accepted as a DR at the March, 2024 meeting.]

(From submission #456.)

With the adoption of P1907R1, non-type template parameters of floating-point types have been introduced. It is surprising that a double value cannot be passed as a template argument for a template parameter of type long double, because floating-point conversions are not allowed in converted constant expressions.

History
Date User Action Args
2024-07-20 13:52:34adminsetstatus: dr -> drwp
2024-04-05 21:43:46adminsetstatus: ready -> dr
2024-03-20 14:10:31adminsetstatus: tentatively ready -> ready
2024-02-16 23:23:05adminsetstatus: open -> tentatively ready
2024-02-03 19:47:49adminsetmessages: + msg7590
2023-11-03 00:00:00admincreate