C++ Logo

std-discussion

Advanced search

Padding bits stability

From: Mykola Garkusha <garkusha.mykola_at_[hidden]>
Date: Sun, 10 Nov 2024 20:45:17 +0000
Hi all,

Currently(unlike C), the standard does not guarantee that padding bits may
retain specific values even between sequential reads. Let's exclude tail
padding re-use for potentially-overlapping sub-objects. as it is a slightly
different matter related to OOP in C++ .

In C, padding bits are guaranteed to say the same unless you modify the
value! Also looks like Clang and GCC also follow it, particularly to
facilitate atomic operations on objects with padding bits. Clang and GCC
even go further by providing intrinsics to clear padding bits (for example
*__builtin_clear_padding* in GCC).

Is there any chance C++ standard would allow this officially to come closer
to the behaviour in C?

Kind Regards,
  Mykola

Received on 2024-11-10 20:45:31