bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Define alignof_slot using _Alignof when using C11 or newer


From: Paul Eggert
Subject: Re: [PATCH] Define alignof_slot using _Alignof when using C11 or newer
Date: Sat, 14 Jan 2023 17:59:12 -0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2

On 2023-01-14 16:17, Bruno Haible wrote:
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."

I'm afraid this wording in n3047 is unclear. Ordinarily one would look at n3047's section "Type definitions" to interpret the phrase "defines a new type", but as that section merely talks about typedefs it doesn't seem to be relevant here. I can't find any part of the standard that talks about "defining a new type".

All the standardizers wanted here is for the TYPE to not contain a top-level comma in 'offsetof (TYPE, MEMBER)' because that would screw up macro argument identification.

I hope Clang 16 is not reporting an error for 'offsetof (struct {char a; int b;}, b)'; if so, it's gone off the deep end. A nameless struct does not "define a new type" for some reasonable definitions of the term "define a new type", and since the standard doesn't define that term the Clang developers should be cautious about diagnostics in this messy area when a lot of code out there uses offsetof in precisely this way.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]