Date: Wed, 27 Aug 2025 14:22:44 +0000
reinterpret_cast is runtime only and works for pointers and references.
bit_cast is constexpr and works with values.
From: Std-Proposals <std-proposals-bounces_at_[hidden]socpp.org> On Behalf Of Sebastian Wittmeier via Std-Proposals
Sent: Wednesday, August 27, 2025 15:28
To: std-proposals_at_[hidden]
Cc: Sebastian Wittmeier <wittmeier_at_[hidden]>
Subject: Re: [std-proposals] TBAA and extended floating-point types
How would you distinguish reinterpret_cast from bit_cast?
Only the type (pointer or reference vs. value)?
-----Ursprüngliche Nachricht-----
Von: Henry Miller via Std-Proposals <std-proposals_at_[hidden]<mailto: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.
bit_cast is constexpr and works with values.
From: Std-Proposals <std-proposals-bounces_at_[hidden]socpp.org> On Behalf Of Sebastian Wittmeier via Std-Proposals
Sent: Wednesday, August 27, 2025 15:28
To: std-proposals_at_[hidden]
Cc: Sebastian Wittmeier <wittmeier_at_[hidden]>
Subject: Re: [std-proposals] TBAA and extended floating-point types
How would you distinguish reinterpret_cast from bit_cast?
Only the type (pointer or reference vs. value)?
-----Ursprüngliche Nachricht-----
Von: Henry Miller via Std-Proposals <std-proposals_at_[hidden]<mailto: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.
Received on 2025-08-27 14:22:49