Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751655AbbETHfI (ORCPT ); Wed, 20 May 2015 03:35:08 -0400 Received: from mout.gmx.net ([212.227.15.15]:64582 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750800AbbETHfF (ORCPT ); Wed, 20 May 2015 03:35:05 -0400 Message-ID: <555C38F2.7060402@gmx.net> Date: Wed, 20 May 2015 09:34:10 +0200 From: Jens Maurer User-Agent: Mozilla/5.0 (X11; Linux i686; rv:6.0.1) Gecko/20110830 Thunderbird/6.0.1 MIME-Version: 1.0 To: c++std-parallel@accu.org CC: "Paul E. McKenney" , Linus Torvalds , Linux Kernel Mailing List , "linux-arch@vger.kernel.org" , "gcc@gcc.gnu.org" , p796231 , "mark.batty@cl.cam.ac.uk" , Peter Zijlstra , Will Deacon , Ramana Radhakrishnan , David Howells , Andrew Morton , Ingo Molnar , michaelw@ca.ibm.com Subject: Re: [c++std-parallel-1614] Re: Compilers and RCU readers: Once more unto the breach! References: <20150520005510.GA23559@linux.vnet.ibm.com> <20150520023402.GC6776@linux.vnet.ibm.com> In-Reply-To: <20150520023402.GC6776@linux.vnet.ibm.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:37BxOulssg1C42k8ETjdYXJKFopalqZSWcN2/1w7Ldlg1rjDI7V GAEoS8ccN2knvd0D38rPc9m5+DflUmeyJhDuanJwWP738yca3TWV4XK8KLpkdYRe40++Dj0 crzvgnTtJP1Ib6I5UN8BRClgdAdAZXHqTqi4aRToLqnIwb2bjLxWobIAquOArEotnasdC8f y0VwXM6iASkUIvFfTzWSw== X-UI-Out-Filterresults: notjunk:1; Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1453 Lines: 35 On 05/20/2015 04:34 AM, Paul E. McKenney wrote: > On Tue, May 19, 2015 at 06:57:02PM -0700, Linus Torvalds wrote: >> - the "you can add/subtract integral values" still opens you up to >> language lawyers claiming "(char *)ptr - (intptr_t)ptr" preserving the >> dependency, which it clearly doesn't. But language-lawyering it does, >> since all those operations (cast to pointer, cast to integer, >> subtracting an integer) claim to be dependency-preserving operations. [...] > There are some stranger examples, such as "(char *)ptr - ((intptr_t)ptr)/7", > but in that case, if the resulting pointer happens by chance to reference > valid memory, I believe a dependency would still be carried. [...] >From a language lawyer standpoint, pointer arithmetic is only valid within an array. These examples seem to go beyond the bounds of the array and therefore have undefined behavior. C++ standard section 5.7 paragraph 4 "If both the pointer operand and the result point to elements of the same array object, or one past the last element of the array object, the evaluation shall not produce an overflow; otherwise, the behavior is undefined." C99 and C11 identical phrasing in 6.5.6 paragraph 8 Jens -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/