C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Fixing std::bit_cast padding bit issues

From: David Brown <david.brown_at_[hidden]>
Date: Fri, 16 Jan 2026 17:40:32 +0100
On 16/01/2026 17:18, Thiago Macieira via Std-Proposals wrote:
> On Friday, 16 January 2026 08:05:59 Pacific Standard Time David Brown via Std-
> Proposals wrote:
>> I think it is very rare in practice that padding bits or bytes will not
>> be copied when the rest of a struct (or type with padding bits) is
>> copied. Usually omitting those would be a pessimisation, not an
>> optimisation.
>
> It happens *all* the time with long double. And it depends on *how* the thing
> is copied. If it is done by copying memory, the bits will come through. If it
> is done by the x87 stack, they will not and the destination's previous bits
> will remain unchanged.
>

I did not think x87 floating point was much used any more - my
understanding was that floating point was primarily handled with SIMD
instructions and registers for greater efficiency. But my knowledge
here is minimal (I target small embedded systems), so I accept your
experience.

Received on 2026-01-16 16:40:39