C++ Logo

std-proposals

Advanced search

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

From: Thiago Macieira <thiago_at_[hidden]>
Date: Fri, 23 Jan 2026 15:03:38 -0800
On Friday, 23 January 2026 14:01:35 Pacific Standard Time Andrey Semashev via
Std-Proposals wrote:
> > [1] https://gcc.godbolt.org/z/Wxdxbjao5
>
> Interesting, thanks for the code sample.
>
> However, I do not find where the standard permits padding bits (or, more
> generally, the object representation) to change out of thin air, without
> a modifying operation on the object. I tend to think this might be a
> compiler bug.

But is there language saying they must be retained?

It's possible that under *current* rules saying they are indeterminate, any
attempt to compare them is itself UB/EB, and therefore it doesn't matter if
they change or not.

This may be worth a Defect Report.

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

Received on 2026-01-23 23:03:49