C++ Logo

std-proposals

Advanced search

Re: [std-proposals] std::sizeof_minus_trailing_padding

From: Thiago Macieira <thiago_at_[hidden]>
Date: Fri, 01 Dec 2023 10:47:31 +0100
On Friday, 1 December 2023 10:03:45 CET Frederick Virchanza Gotham via Std-
Proposals wrote:
> I don't see why the committee would need to see this in a few
> compilers before determining that what I've done in the above Godbolt
> is useful.

Maybe the solution isn't to standardise this operator, but to standardise a
way to use the tail padding in a way controlled by the compiler, so it can be
certain it is only used if it is allowed. That avoids having you guess whether
the tail padding in a trivially-copyable type can used or not: the ABI
decides.

I am also skeptical that you're allowed to use the tail padding in your A
class in the example. It isn't trivially copyable, but why wouldn't the
members in that class be allowed to use the full sizeof(A) in this?

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel DCAI Cloud Engineering

Received on 2023-12-01 09:47:39