From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.2 Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by inbox.vuxu.org (OpenSMTPD) with SMTP id a6677bd9 for ; Sun, 19 Jan 2020 21:02:18 +0000 (UTC) Received: (qmail 12030 invoked by uid 550); 19 Jan 2020 21:02:16 -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 12012 invoked from network); 19 Jan 2020 21:02:16 -0000 To: musl@lists.openwall.com References: <20200119110743.GD2020@voyager> <20200119113134.GJ23985@port70.net> <8299f261-7870-57a6-37cf-d4ce482ad81e@openwall.com> <20200119142401.GG2020@voyager> <20200119162233.GD30412@brightrain.aerifal.cx> From: Alexander Cherepanov Message-ID: Date: Mon, 20 Jan 2020 00:02:04 +0300 MIME-Version: 1.0 In-Reply-To: <20200119162233.GD30412@brightrain.aerifal.cx> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [musl] Minor style patch to exit.c On 19/01/2020 19.22, Rich Felker wrote: >> Even if we know that _start + k == _end it doesn't mean that we >> allowed to subtract them. > > Consider a function that takes a pointer p, an array a, and a length > l, and does: > > for (i=0; i > Can f(_end,_start,k) and f(_start+k,_start,k) legitimately differ, > despite _end==_start+k? I guess it depends on what you mean by "legitimately" and "differ". Given that _start and _end are different arrays the first variant is undefined. Counter-intuitive behavior of equal pointers could be demonstrated much easier. Suppose x and y are two objects of the same type and &x + 1 == &y. Is it valid to evaluate the following expressions: *(&x + 1), &x + 2, (&y)[-1]? > I think the answer is no, in the existing C > language, in that the result of an expression is a pure function of > the *values* put into it. The fact that two values are equal doesn't mean that they are the same value. Take floating-point zeroes for example. They are equal but have different provenances: one came from the right, another one -- from the left:-) > But compiler folks do not want to interpret > it this way and are pushing through hidden "provenance" state, so... IIUC they are not happy about it too but the alternatives are not that great. -- Alexander Cherepanov