C++ Logo

std-proposals

Advanced search

Re: [std-proposals] REVIEW Needed: Relax narrowing for lossless integer → ISO/IEC 60559 binary floating conversions

From: Giuseppe D'Angelo <giuseppe.dangelo_at_[hidden]>
Date: Tue, 20 Jan 2026 13:11:30 +0100
Il 20/01/26 12:07, Dmytro Ovdiienko via Std-Proposals ha scritto:
> I'd like to submit the proposal regarding relaxing the narrowing int ->
> floating conversion.
>
> Abstract
>
> This paper proposes relaxing list-initialization narrowing rules so that
> an implicit conversion from an integer type to a floating-point type is
> not considered narrowing when the destination floating-point type
> adheres to ISO/IEC 60559, has a binary radix, and has sufficient
> precision to exactly represent all values of the source integer type.

As far as I've understood, the rules of narrowing are deliberately done
in order to be "portable"; that is, they don't depend on specifics of
the integer or floating-point types involved.

This has implications like the one you've described: int -> double is
narrowing even if it's exact on any "common" platform; or similarly that
long double -> double is narrowing even when the two types are the same
on a specific platform (x64 MSVC).

I had a proposal in the works for a more precise trait along the lines
of what you're describing (P2509), but I've stalled the work on it due
to lack of time.

Thank you,
--
Giuseppe D'Angelo

Received on 2026-01-20 12:11:33