Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMbjb12WQL+DQSP0xXy84fNTEGTbE2DX1=oX-Wc_s2wyRAxypg@mail.gmail.com>
Date: Mon, 18 Mar 2024 17:01:41 -0700
From: Mike Cui <cuicui@...il.com>
To: NRK <nrk@...root.org>
Cc: musl@...ts.openwall.com
Subject: Re: Potential bug in __res_msend_rc() wrt to union initialization.

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@...root.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
>

Content of type "text/html" skipped

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.