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.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,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 8672C211E9 for ; Wed, 20 Mar 2024 18:11:34 +0100 (CET) Received: (qmail 11627 invoked by uid 550); 20 Mar 2024 17:07:00 -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 11592 invoked from network); 20 Mar 2024 17:07:00 -0000 X-Virus-Scanned: SPAM Filter at disroot.org Date: Wed, 20 Mar 2024 17:11:16 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1710954679; bh=5prD0/ciIsXX2FqeucxMrx+6vGt54Qv2noIMSK9bhUI=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=TKzrTauhTc7G3ZKQ4DsCN1P+juxCK1FmmVsa5gggtK4tYarXpC7noh2AwNCa6GHdi vokZ8RhWfUSN1UWj1S/q+xJXe6YosN4yNUmZblT/BKSuuDMaSgk/b4ETl+7JEm0X7s /sQChhIO0vUfjb7lmWwMAsNyWpUjhBNWgkDC/573G4M41YeX01NJThhuGOM1CMz3OQ RrVoIEW57GE9VPTJ44d4z/9KLAT1gSjYqR6E/vwq67R3misup7HhfTbL17G/E7h2kA 1EIxjxogHILEI97j+jwVXPH1o8VhzjKTfCMxYxCMAgzPz2Q8FmkIbJ3WFWsJqBUA05 XgzqQMiSM7EHA== From: NRK To: Rich Felker Cc: =?utf-8?B?SuKCkeKCmeKCmw==?= Gustedt , musl@lists.openwall.com, Mike Cui Message-ID: References: <627epdel4gidvu46u5ua2mclieqy3wwqbs7sxjgtgrsmkvn4up@ehu5ru6micnr> <20240319131833.GI4163@brightrain.aerifal.cx> <20240319154222.GK4163@brightrain.aerifal.cx> <20240319160832.GL4163@brightrain.aerifal.cx> <20240319173930.57b8eb30@inria.fr> <20240319213640.GN4163@brightrain.aerifal.cx> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20240319213640.GN4163@brightrain.aerifal.cx> Subject: Re: [musl] Potential bug in __res_msend_rc() wrt to union initialization. > That's simply not true. There is no difference in the rules as > specified by the standard. I don't think your assertion is correct, at least it hasn't been demonstrated. > ¶19 says: > > "all subobjects that are not initialized explicitly shall be > initialized implicitly the same as objects that have static > storage duration." > > The term "subobject" does not seem to be defined, so there's some > ambiguity, but I would read ¶19 as applying the above text about > static unions to automatic ones. The term subobject might not be clearly defined but there's a strong indication that it refers to objects contained within an aggregate, and NOT members of a union. Consider the following case: struct { int a; int b; } object = { .a = 5 }; Assuming `a` and `b` are subobjects, `a` will be initialized to 5 and `b` to 0. Which makes sense and is consistent with all existing implementation I'm aware of. Now consider the same with a union: union { int a; int b; } object = { .a = 5 }; If `b` is a subobjects then it should be initialized to zero according to the rule. But that can't happen since that'd overwrite the value of `a`. This to me is a convincing case that subobjects do not refer to union members, as there can be only 1 active at a time. Now I don't agree with clang's decision to not zero the entire union in case of `{0}`. It's unnecessarily hostile, brings negligible (if any) gains and *will* be causing bugs (this is the 2nd one I'm witnessing). But as it currently stands, it's not a wrong interpretation of the standard either. If the intention was to have no difference between {0} and {} it has not been written down clearly. - NRK