C++ Logo

std-proposals

Advanced search

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

From: Henry Miller <hank_at_[hidden]>
Date: Wed, 27 Aug 2025 08:46:49 -0500
On Wed, Aug 27, 2025, at 08:27, Sebastian Wittmeier via Std-Proposals wrote:
> How would you distinguish reinterpret_cast from bit_cast?

I'm stuck with c++17 for most of my code for another year so I forgot about bit_cast and am not familiar with the details. If you mean to correct me that I should have said bit_cast then I'll stand corrected. (Someone else can argue the point if they want - in fact I hope someone does respond with how they should be different in this case and what to use)

either way I think it is static_cast we want here.

> Only the type (pointer or reference vs. value)?
>
> -----Ursprüngliche Nachricht-----
> Von:Henry Miller via Std-Proposals <std-proposals_at_[hidden]>
>
> You want static_cast here not reinterpret_cast. If that is paper it
> should be revised. Reinterpret_cast has always been "hey compiler,
> trust me that these bits don't really mean what the type says they
> mean, treat them as this other type and shut up about it". Static_cast
> has always been you know how to treat these bits in a different way, so
> please apply that (error if you don't know how). In your example it
> makes no difference as the two types happen to have the same bits.
>
>
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals

Received on 2025-08-27 13:47:11