mailing list of musl libc
 help / color / mirror / code / Atom feed
* [musl] Re: Re: Potential bug in __res_msend_rc() wrt to union
@ 2024-03-19 16:32 Aaron Peter Bachmann
  0 siblings, 0 replies; only message in thread
From: Aaron Peter Bachmann @ 2024-03-19 16:32 UTC (permalink / raw)
  To: musl

On Tue, 19 Mar 2024 09:18:33 -0400 Rich Felker  wrote:
>C11 adds (in 6.7.9 ¶10):
>
>    "if it is a union, the first named member is initialized
>    (recursively) according to these rules, and any padding is
>    initialized to zero bits;"
>
>where C99 just had (6.7.8):
>
>    "if it is a union, the first named member is initialized
>    (recursively) according to these rules."
>
>So I think C11 and later actually require the full zero
>initialization of all bits, and clang is just wrong.

"all bits" is a bit misleading, as it does not cover padding
(alignment holes and anonymous bit-fileds and holes due to bit-fields).
At least that is what I think the standard says.
The compiler is likely to implement "all bits".
C23 ... = { } - without 0 between the braces - really includes "all bits" but even recent C++ does not.

Regards, Aaron Peter Bachmann



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-03-19 18:02 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-19 16:32 [musl] Re: Re: Potential bug in __res_msend_rc() wrt to union Aaron Peter Bachmann

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).