bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
From: Khem Raj <raj.khem@gmail.com>
To: Bruno Haible <bruno@clisp.org>
Cc: bug-gnulib@gnu.org
Subject: Re: [PATCH] Define alignof_slot using _Alignof when using C11 or newer
Date: Sat, 14 Jan 2023 17:20:05 -0800	[thread overview]
Message-ID: <CAMKF1sq0d0eXsNMhEdLeUTUo8WeLdJKJH4gMpuJ805-BDWa=Bw@mail.gmail.com> (raw)
In-Reply-To: <4385269.dumfJixkPq@nimes>

On Sat, Jan 14, 2023 at 4:17 PM Bruno Haible <bruno@clisp.org> wrote:
>
> Khem Raj wrote:
> > [2] https://reviews.llvm.org/D133574
>
> Thanks for the heads-up.
>
> > WG14 N2350 made very clear that it is an UB having type definitions
> > within "offsetof" [1].
> > [1] https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2350.htm
>
> This document is not normative; it is merely a discussion document.
>
> What's (quasi) normative is
>
>   * n3047.pdf = C23, which says in 7.21.(3)
>     "If the specified type defines a new type or if the specified member is
>      a bit-field, the behavior is undefined."
>
>   * n2176.pdf = C18, which in 7.19.(3) merely says
>     "If the specified member is a bit-field, the behavior is undefined."
>
> So, only C23 and higher require to avoid offsetof with a new type.
>
> Since gnulib/lib/stdalign.h mentions an _Alignof bug in older versions of
> GCC and clang and some of these older versions (e.g. GCC 4.8.5) support C11,
> it is better to enable the workaround only for C23 and higher, not for
> C11 and higher.
>

I think if its enabled only for c2x and newer, clang will still errors out  for
__STDC_VERSION__= 201710L
I have sent out a patch which replicates the logic from
gnulib/lib/stdalign.h.in which should
address this as well.

> > +#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L && !defined(__cplusplus)
>
> The '!defined(__cplusplus)' part is redundant here.
>

right. Dropped in v2.

> Bruno
>
>
>


  reply	other threads:[~2023-01-15  1:20 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-14 23:27 [PATCH] Define alignof_slot using _Alignof when using C11 or newer Khem Raj
2023-01-15  0:17 ` Bruno Haible
2023-01-15  1:20   ` Khem Raj [this message]
2023-01-15  1:59   ` Paul Eggert

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

  List information: https://lists.gnu.org/mailman/listinfo/bug-gnulib

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

  git send-email \
    --in-reply-to='CAMKF1sq0d0eXsNMhEdLeUTUo8WeLdJKJH4gMpuJ805-BDWa=Bw@mail.gmail.com' \
    --to=raj.khem@gmail.com \
    --cc=bruno@clisp.org \
    --cc=bug-gnulib@gnu.org \
    /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.
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 read-only IMAP folder(s) and NNTP newsgroup(s).