C++ Logo

std-proposals

Advanced search

Re: [std-proposals] TBAA and extended floating-point types

From: Henry Miller <hank_at_[hidden]>
Date: Tue, 26 Aug 2025 16:27:57 -0500
On Tue, Aug 26, 2025, at 15:44, Sebastian Wittmeier via Std-Proposals wrote:
> I can understand some general reasons for the push-back on allowing aliasing.
>
>
> But specifically double and std::float64_t on platforms, where they
> have the same representation:
>
>
> What is gained by disallowing aliasing? Wouldn't it just be defined as
> a typedef on those platforms?
>
>
> You find yourself agreeing (with disallowing), can you explain?

The issues is there are platforms where they are different, and for the people who work on such system that difference is important and share code with people who work on systems where they are the same. We also don't know the future - by defining the bits in std::float64_t we tie our hands in ways that probably won't even matter to most code that just wants a floating point value.

Of course against the above: I have little hope that developers will get the distinction right anyway, but we at least give assistance to people who know they need a specific layout (and I wonder how many of them will be wrong...). This argument makes std::float64_t the wrong type to use for most situations - you should use it only when you are communicating the value to some other system, or other situations where standard math is required not whatever the hardware implements.

Received on 2025-08-26 21:28:20