From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27292 invoked by alias); 1 Mar 2008 02:05:39 -0000 Received: (qmail 27197 invoked by uid 22791); 1 Mar 2008 02:05:39 -0000 X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sat, 01 Mar 2008 02:05:19 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id D35EF2A9FB5; Fri, 29 Feb 2008 21:05:17 -0500 (EST) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id kI9c9g0yLZGf; Fri, 29 Feb 2008 21:05:17 -0500 (EST) Received: from [127.0.0.1] (nile.gnat.com [205.232.38.5]) by rock.gnat.com (Postfix) with ESMTP id 97C462A9FB3; Fri, 29 Feb 2008 21:05:17 -0500 (EST) Message-ID: <47C8B9D4.1000906@adacore.com> Date: Sat, 01 Mar 2008 02:05:00 -0000 From: Robert Dewar User-Agent: Thunderbird 2.0.0.12 (Windows/20080213) MIME-Version: 1.0 To: Richard Kenner CC: mark@codesourcery.com, gcc-patches@gcc.gnu.org, gcc@gcc.gnu.org, rguenther@suse.de Subject: Re: [PATCH][4.3] Deprecate -ftrapv References: <47C89DB1.6030200@codesourcery.com> <10803010013.AA29088@vlsi1.ultra.nyu.edu> In-Reply-To: <10803010013.AA29088@vlsi1.ultra.nyu.edu> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2008-03/txt/msg00014.txt.bz2 Richard Kenner wrote: >> Why doesn't it work? Can it be made to work relatively easily? Do we >> need functionality like this for Ada or Java? > > Ada currently has to do this itself, precisely because -ftrapv doesn't > work, so it's not the case that Ada "needs" it. Well no one "needs" anything in this sense, any interfaced is Turing complete so there is *always* a work around deficiencies in the back end. But right now, the "do this itself" is really horribly inefficient: > procedure k (x : out integer; y,z : integer) is > begin > x := y + z; > end; > procedure k (x : out integer; y : integer; z : integer) is > begin > [constraint_error when > not (long_long_integer?(y) + long_long_integer?(z) in > -16#8000_0000# .. 16#7FFF_FFFF#) > "overflow check failed"] > x := integer?(long_long_integer?(y) + long_long_integer?(z)); > return; > end k; assembly language (-O2) with -gnato to enable overflow checking > __ada_k: > LFB3: > pushl %ebp > LCFI0: > movl %esp, %ebp > LCFI1: > pushl %ebx > LCFI2: > subl $4, %esp > LCFI3: > movl 8(%ebp), %eax > movl 12(%ebp), %ecx > movl %eax, %edx > movl %ecx, %ebx > sarl $31, %edx > sarl $31, %ebx > addl %eax, %ecx > adcl %edx, %ebx > movl %ecx, %eax > addl $-2147483648, %eax > movl %ebx, %edx > adcl $0, %edx > cmpl $0, %edx > jbe L6 > pushl %eax > pushl %eax > pushl $3 > pushl $LC0 > LCFI4: > call ___gnat_rcheck_10 > .p2align 4,,7 > L6: > movl %ecx, %eax > movl -4(%ebp), %ebx > leave > ret pretty gruesome :-(