C++ Logo


Advanced search

Re: [std-proposals] [[packed]] std::unaligned

From: Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>
Date: Sun, 10 Dec 2023 16:22:23 +0000
Replying to Arthur and Lénárd in series below . . .

On Sunday, December 10, 2023, Arthur O'Dwyer wrote:

> However, I don't think Frederick has realized yet that his "packed
> TokenInfo" (where the attribute cracks open the curly braces and applies
> itself to all subobjects recursively) *is-not-a* kind of "TokenInfo".
> There are things you can do with a "TokenInfo" which you physically cannot
> do with such a "packed TokenInfo." One example is "fetch its `c` member
> with an aligned load instruction" (because the packed TokenInfo's `c` is
> misaligned). Another example is "evaluate `&p->c` and have it give you a
> pointer of type `long unsigned*`" (because the language assumes that it's
> always safe to load from a `long unsigned*` using an aligned load
> instruction).

I wasn't forgetting about this -- I addressed it with my proposed three
rules in my original post:


Lénárd posted the same day:
> And lift the ban on specifying
> lower than the types alignment
> for members.

Actually it would be interesting if we could do the following:

   struct Monkey {
        alignas(1) long unsigned a;
        alignas(1) char b;
        alignas(1) long unsigned c;
        alignas(1) char d;

Received on 2023-12-10 16:22:26