Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAA2zVHqZrZOSSeiqmY_HX-V62v6gGxyD+QJ45aRLrUKRG5xjyw@mail.gmail.com>
Date: Thu, 12 Mar 2026 15:09:59 -0400
From: James Y Knight <jyknight@...gle.com>
To: Rich Felker <dalias@...c.org>
Cc: musl@...ts.openwall.com, Xing Li <lixing@...ngson.cn>, wanghongliang@...ngson.cn
Subject: Re: [PATCH] loongarch64: Add lsx and lasx regset definition

On Wed, Mar 11, 2026 at 12:24 PM Rich Felker <dalias@...c.org> wrote:
> I'm not sure how GNU C __attribute__((__aligned__(...))) even binds,
> which is part of why I don't like it and prefer the clearer ISO C
> form.

The rules for where GNU C attributes are indeed somewhat tricky. But
in this case: the original was applied to the typedef (the entity
immediately to the left), and in my first suggestion, it applied to
the union type (again, the entity immediately to the left).

> > typedef union
> > {
> >      _Alignas(16) double d[2];
> >      _Alignas(16) float f[4];
> > } elf_lsxregset_t[32];
>
> Does that work? Or would that be trying to apply the alignment to
> double where the alignment is larger than the type and thereby
> invalid? This is totally on me, but I don't understand well how the
> binding works.

Yep, it works. And the standard rules are quite simple: in C, alignas
may _only_ be applied to structure fields or local/global variables --
not to types (or parts of types), at all. In C++, it may also be
applied to an entire struct/class/union, so, e.g. `struct alignas(64)
Foo { int x; };` is valid only in C++. Neither standard permits it to
be applied to a typedef, or other such "interesting" usage.

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.