mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Michael Forney <mforney@mforney.org>
To: musl@lists.openwall.com
Subject: Re: [musl] Alignment attribute in headers
Date: Sun, 21 Apr 2024 12:04:30 -0700	[thread overview]
Message-ID: <3EBS8QD55K8YJ.3M8DNLQQKVDYL@mforney.org> (raw)
In-Reply-To: <ZiVK9imGJ_PAaHID@voyager>

Markus Wichmann <nullplan@gmx.net> wrote:
> Am Sun, Apr 21, 2024 at 03:50:31PM +0000 schrieb Thorsten Glaser:
> > I haven’t looked at the C11 one.
> 
> C11's _Alignas can only raise alignment, not lower it. Alignment
> specifications with a lower number than the field already has are
> ignored. I can't believe the C++ guys screwed up so hard as to make
> lower alignment UB.

It's true that _Alignas can't lower alignment, but it's not ignored
if you specify a weaker alignment, it's a constraint violation:

C17 6.7.5p5:
> The combined effect of all alignment specifiers in a declaration
> shall not specify an alignment that is less strict than the
> alignment that would otherwise be required for the type of the
> object or member being declared.

This doesn't matter for the proposed alignment specifiers since
they are in architecture-specific headers where we know that the
specified alignment is not less than is required for the type.

However, in general, I think Thorsten's concern is valid. If you
specify some alignment that your application needs, but the
implementation already requires a stricter alignment, your program
has an error.

You could work around it by specifying two alignment specifiers:

	_Alignas(N) _Alignas(T) T x;

But anyway, this has veered a bit off-topic.

  parent reply	other threads:[~2024-04-21 19:04 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-21  3:51 Michael Forney
2024-04-21  4:54 ` Markus Wichmann
2024-04-21  7:16   ` Jₑₙₛ Gustedt
2024-04-21  7:38     ` Markus Wichmann
2024-04-21 10:23       ` Jₑₙₛ Gustedt
2024-04-21 10:31         ` Sam James
2024-04-21 17:40         ` Markus Wichmann
2024-04-21 15:50 ` Thorsten Glaser
2024-04-21 16:44   ` Alexander Monakov
2024-04-21 17:20   ` Markus Wichmann
2024-04-21 18:23     ` Thorsten Glaser
2024-04-21 19:04     ` Michael Forney [this message]
2024-04-21 23:48 ` Rich Felker
2024-04-24  0:45   ` Michael Forney
2024-04-24  2:54     ` Markus Wichmann
2024-04-24  7:39     ` Jon Chesterfield
2024-04-24  7:55       ` Jeffrey Walton
2024-04-24  9:49         ` Jon Chesterfield

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3EBS8QD55K8YJ.3M8DNLQQKVDYL@mforney.org \
    --to=mforney@mforney.org \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).