You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Issue description: Prior to the adoption of P1907R1, which allowed non-type template parameters to be of floating-point type, there was nothing in the language that could require a converted constant expression of floating-point type. Since P1907R1 has been adopted, it is surprising that a double value can't be passed as a template argument for a template parameter of type long double.
The rules for narrowing floating-point conversions, [dcl.init.list]/7.2, might not be strict enough. We might want to disallow any conversion where the destination type can't represent the source value exactly. Or we might want to be even more strict and disallow conversion to lower rank even when the source value can be represented exactly.
Suggested resolution: Add two bullets after [expr.const]/12.7:
[...]
integral promotions,
integral conversions other than narrowing conversions,
floating-point promotions,
floating-point conversions where the source value can be represented exactly in the destination type,
null pointer conversions from std::nullptr_t,
[...]
Alternative suggested resolution: Add two bullets after [expr.const]/12.7:
[...]
integral promotions,
integral conversions other than narrowing conversions,
floating-point promotions,
floating-point conversions where the floating-point conversion rank of the destination type is greater than or equal to that of the source type,
null pointer conversions from std::nullptr_t,
[...]
The text was updated successfully, but these errors were encountered:
jensmaurer
changed the title
[expr.const] Non-narrowing floating-point conversions should be allowed in converted constant expressions
CWG2851 [expr.const] Non-narrowing floating-point conversions should be allowed in converted constant expressions
Feb 3, 2024
Full name of submitter: Brian Bi
Reference (section label): [expr.const]
Issue description: Prior to the adoption of P1907R1, which allowed non-type template parameters to be of floating-point type, there was nothing in the language that could require a converted constant expression of floating-point type. Since P1907R1 has been adopted, it is surprising that a
double
value can't be passed as a template argument for a template parameter of typelong double
.The rules for narrowing floating-point conversions, [dcl.init.list]/7.2, might not be strict enough. We might want to disallow any conversion where the destination type can't represent the source value exactly. Or we might want to be even more strict and disallow conversion to lower rank even when the source value can be represented exactly.
Suggested resolution: Add two bullets after [expr.const]/12.7:
Alternative suggested resolution: Add two bullets after [expr.const]/12.7:
The text was updated successfully, but these errors were encountered: