Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Mon, 18 Mar 2024 22:22:55 +0000
From: NRK <nrk@...root.org>
To: musl@...ts.openwall.com
Cc: Mike Cui <cuicui@...il.com>
Subject: Re: Potential bug in __res_msend_rc() wrt to union
 initialization.

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

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.