From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1055 invoked by alias); 12 Aug 2011 07:32:26 -0000 Received: (qmail 1046 invoked by uid 22791); 12 Aug 2011 07:32:25 -0000 X-SWARE-Spam-Status: No, hits=-2.2 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,TW_LV X-Spam-Check-By: sourceware.org Received: from mail-yw0-f47.google.com (HELO mail-yw0-f47.google.com) (209.85.213.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 12 Aug 2011 07:32:12 +0000 Received: by ywe9 with SMTP id 9so1888616ywe.20 for ; Fri, 12 Aug 2011 00:32:11 -0700 (PDT) MIME-Version: 1.0 Received: by 10.150.243.5 with SMTP id q5mr505629ybh.421.1313134331537; Fri, 12 Aug 2011 00:32:11 -0700 (PDT) Received: by 10.150.219.17 with HTTP; Fri, 12 Aug 2011 00:32:11 -0700 (PDT) In-Reply-To: <59662D5BB74CD84D9FA8E6491ADB51A7DEAE4D29@US01WXMBX1.internal.synopsys.com> References: <201108111715.14240.florian.merz@kit.edu> <201108111805.19582.florian.merz@kit.edu> <59662D5BB74CD84D9FA8E6491ADB51A7DEAE4D29@US01WXMBX1.internal.synopsys.com> Date: Fri, 12 Aug 2011 07:32:00 -0000 Message-ID: Subject: Re: [LLVMdev] Handling of pointer difference in llvm-gcc and clang From: Richard Guenther To: Joe Buck Cc: Gabriel Dos Reis , "Joseph S. Myers" , "florian.merz@kit.edu" , "gcc@gcc.gnu.org" Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org X-SW-Source: 2011-08/txt/msg00240.txt.bz2 On Thu, Aug 11, 2011 at 10:36 PM, Joe Buck wrote: > On Thu, Aug 11, 2011 at 1:58 PM, Joseph S. Myers > wrote: >> =A0-ftrapv and -fwrapv should have no effect on pointer subtraction. > > Gaby writes: > >> Yes! > > Wouldn't it suffice to convert the pointers to unsigned, do an unsigned s= ubtraction, and then convert the result to signed? This would then guarante= e that gcc uses two's complement semantics, independent of -ftrapv. Of course, I think that is what is being proposed. Richard.