Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

CWG2851 [expr.const] Non-narrowing floating-point conversions should be allowed in converted constant expressions #456

Copy link
Copy link
Closed
cplusplus/draft
#6906
cplusplus/draft#6906
@t3nsor

Description

@t3nsor
Issue body actions

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 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,
  • [...]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.