Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <cfc74b71-d018-4a57-9558-4a43e6978658@inode.at>
Date: Tue, 19 Mar 2024 17:32:09 +0100
From: Aaron Peter Bachmann <aaron_ng@...de.at>
To: musl@...ts.openwall.com
Subject: Re: Re: Potential bug in __res_msend_rc() wrt to union

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


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.