mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Mike Cui <cuicui@gmail.com>
To: NRK <nrk@disroot.org>
Cc: musl@lists.openwall.com
Subject: Re: [musl] Potential bug in __res_msend_rc() wrt to union initialization.
Date: Mon, 18 Mar 2024 17:01:41 -0700	[thread overview]
Message-ID: <CAMbjb12WQL+DQSP0xXy84fNTEGTbE2DX1=oX-Wc_s2wyRAxypg@mail.gmail.com> (raw)
In-Reply-To: <627epdel4gidvu46u5ua2mclieqy3wwqbs7sxjgtgrsmkvn4up@ehu5ru6micnr>

[-- Attachment #1: Type: text/plain, Size: 1066 bytes --]

Yeah I also just went over the C99 spec as well, section 6.7.8, and I have
to agree with clang developer's interpretation, that "{ 0 }"
only initializes the first member of the union.

"{ }" apparently is added in C23 as the "universal zero initializer". So
changing the order moving sin6 up is the only way to be C99 conformant.

On Mon, Mar 18, 2024 at 3:22 PM NRK <nrk@disroot.org> wrote:

> On Mon, Mar 18, 2024 at 05:34:42PM -0400, Rich Felker wrote:
> > If the clang interpretation is going to be this, we can just reorder
> > the union members so that the largest one is first.
>
> Another option is to utilize implicit static initializer rules:
>
> | if it is a union, the first named member is initialized (recursively)
> | according to these rules, and any padding is initialized to zero bits;
>
> So something like:
>
>         static union u zero;
>         union u u = zero;
>
> Though, the "padding bits" part was added in C11 and wasn't present in
> C99 in case you want to be pedantic about C99 conformance.
>
> - NRK
>

[-- Attachment #2: Type: text/html, Size: 1467 bytes --]

  parent reply	other threads:[~2024-03-19  0:02 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-18 19:56 Mike Cui
2024-03-18 21:34 ` Rich Felker
2024-03-18 22:22   ` NRK
2024-03-18 22:39     ` [musl] Potential bug in __res_msend_rc() wrt to union initialisation Thorsten Glaser
2024-03-19  0:01     ` Mike Cui [this message]
2024-03-19 13:18       ` [musl] Potential bug in __res_msend_rc() wrt to union initialization Rich Felker
2024-03-19 15:04         ` Mike Cui
2024-03-19 15:42           ` Rich Felker
2024-03-19 15:55             ` Mike Cui
2024-03-19 16:08               ` Rich Felker
2024-03-19 16:39                 ` Jₑₙₛ Gustedt
2024-03-19 20:47                   ` Thorsten Glaser
2024-03-21 10:58                     ` Jₑₙₛ Gustedt
2024-03-21 16:41                       ` Thorsten Glaser
2024-03-19 21:04                   ` NRK
2024-03-19 21:36                     ` Rich Felker
2024-03-20 17:11                       ` NRK

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='CAMbjb12WQL+DQSP0xXy84fNTEGTbE2DX1=oX-Wc_s2wyRAxypg@mail.gmail.com' \
    --to=cuicui@gmail.com \
    --cc=musl@lists.openwall.com \
    --cc=nrk@disroot.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.
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).