From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.1 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: from second.openwall.net (second.openwall.net [193.110.157.125]) by inbox.vuxu.org (Postfix) with SMTP id 5FC0226E79 for ; Tue, 19 Mar 2024 14:18:27 +0100 (CET) Received: (qmail 1483 invoked by uid 550); 19 Mar 2024 13:13:57 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 1436 invoked from network); 19 Mar 2024 13:13:57 -0000 Date: Tue, 19 Mar 2024 09:18:33 -0400 From: Rich Felker To: Mike Cui Cc: NRK , musl@lists.openwall.com Message-ID: <20240319131833.GI4163@brightrain.aerifal.cx> References: <20240318213441.GH4163@brightrain.aerifal.cx> <627epdel4gidvu46u5ua2mclieqy3wwqbs7sxjgtgrsmkvn4up@ehu5ru6micnr> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Subject: Re: [musl] Potential bug in __res_msend_rc() wrt to union initialization. On Mon, Mar 18, 2024 at 05:01:41PM -0700, Mike Cui wrote: > 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. There is no such thing as "only initializes [part]" in the C language. The { 0 } *only provides a value for* the first member. The question is about what happens to parts of the object for which the initializer did not "provide a value". However, the C99 standard does not clearly describe how the bits of a union that are not part of the member for which a value is provided (usually the first, unless a designated initializer is used) are filled on initialization. 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. > "{ }" 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. Indeed since at the source level we just depend on C99 not C11, this should be changed. But clang needs to be fixed too. Rich