C++ Logo

std-proposals

Advanced search

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

From: Thiago Macieira <thiago_at_[hidden]>
Date: Fri, 16 Jan 2026 08:18:49 -0800
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.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
  Principal Engineer - Intel Data Center - Platform & Sys. Eng.

Received on 2026-01-16 16:18:57