C++ Logo

std-proposals

Advanced search

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

From: Ell <ell.ell.se_at_[hidden]>
Date: Thu, 22 Jan 2026 12:12:12 +0000
On Thursday, January 22nd, 2026 at 7:13 AM, Jan Schultke <janschultke_at_[hidden]> wrote:

>
>
> > I wonder how it plays with guaranteed RVO. If the return value conceptually initializes the result directly, shouldn't that technically include padding? (I guess that's mostly academic, since compilers don't do it in practice)
>
>
> The problem is that it's not observable whether you create one trivially copyable or two trivially copyable objects; in the case of long double, function results are returned via floating-point stack, and there is no padding there.

I was thinking about whether function results can have consistent padding in general, specifically for types that don't fall under the carve-out in <https://eel.is/c++draft/class.temporary#3>. So not super relevant for bit_cast, sorry if it's too OT :)

Received on 2026-01-22 12:12:17