public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Robert Dewar <dewar@adacore.com>
To: Richard Kenner <kenner@vlsi1.ultra.nyu.edu>
Cc: joseph@codesourcery.com, gcc-patches@gcc.gnu.org,
	gcc@gcc.gnu.org,   mark@codesourcery.com, rguenther@suse.de
Subject: Re: [PATCH][4.3] Deprecate -ftrapv
Date: Sat, 01 Mar 2008 14:13:00 -0000	[thread overview]
Message-ID: <47C96481.2050003@adacore.com> (raw)
In-Reply-To: <10803011408.AA02772@vlsi1.ultra.nyu.edu>

Richard Kenner wrote:
>> int f(int a, int b) { return 0 * (a + b); }
>>
>> get the potentially trapping arithmetic folded away.  If -ftrapv is to 
>> have properly defined semantics, those must include trapping if (a + b) 
>> overflows in the above code.
> 
> Why?  Is there any language that requires such semantics?

For C, the above fragment of code is undefined if a+b overflows. Since
the purpose of -ftrapv for C, it is desirable that it catch this case
as well, since gcc might otherwise do peculiar things, or on some other
compiler you might get other peculiar things or a trap etc.

Obviously the C language does not require this, since it does not
require -ftrapv in the first place, that's just a handy addition
that we make to gcc, and we get to decide what's most useful.

For Ada, as I discussed in my last note, max performance says
you can ignore the check here, but generally for max performance
you turn off checks anyway. It is certainly allowed to optimize
this to zero ..

in fact there are two rules that let you optimize the above to
zero in Ada.

1. The rule about correct results for intermediate computations
being OK even if they are out of range.

2. The rule about not doing operations whose only purpose is
to see if they raise a predfined exception.

Certainly it is acceptable to do the check in the Ada case,
and if you are concerned about writing maximally portable
Ada code, desirable.

  parent reply	other threads:[~2008-03-01 14:13 UTC|newest]

Thread overview: 75+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <Pine.LNX.4.64.0803010041110.4133@zhemvz.fhfr.qr>
2008-03-01  0:04 ` Richard Guenther
2008-03-01  0:05 ` Mark Mitchell
2008-03-01  0:11   ` Richard Kenner
2008-03-01  2:05     ` Robert Dewar
2008-03-01  2:17       ` Joseph S. Myers
2008-03-01  2:33         ` Robert Dewar
2008-03-01 13:19           ` Joseph S. Myers
2008-03-01 14:05             ` Paolo Bonzini
2008-03-01 11:24       ` Richard Kenner
2008-03-01 13:55         ` Robert Dewar
2008-03-01 14:12           ` Richard Kenner
2008-03-01 14:18             ` Robert Dewar
2008-03-01  0:14   ` Richard Guenther
2008-03-01  1:04     ` Mark Mitchell
2008-03-01  1:49       ` Joseph S. Myers
2008-03-01  1:54         ` Mark Mitchell
2008-03-01 12:32         ` Richard Guenther
2008-03-01 13:10           ` Joseph S. Myers
2008-03-01 13:38             ` Robert Dewar
2008-03-01 13:57               ` Richard Guenther
2008-03-01 14:05                 ` Robert Dewar
2008-03-01 19:53                   ` Florian Weimer
2008-03-01 20:11                     ` Robert Dewar
2008-03-01 21:19                       ` Florian Weimer
2008-03-01 21:43                         ` Robert Dewar
2008-03-01 21:48                           ` Robert Dewar
2008-03-01 14:14                 ` Richard Kenner
2008-03-01 13:50             ` Richard Guenther
2008-03-01 18:27               ` Joseph S. Myers
2008-03-01 14:06             ` Richard Kenner
2008-03-01 14:10               ` Richard Guenther
2008-03-01 14:15                 ` Robert Dewar
2008-03-01 14:13               ` Robert Dewar [this message]
2008-03-01 14:15               ` Paolo Bonzini
2008-03-01 18:32               ` Joseph S. Myers
2008-03-02 10:47                 ` Mark Mitchell
2008-03-02 11:08                   ` Richard Guenther
2008-03-02 11:52                     ` Robert Dewar
2008-03-03 22:45                       ` Eric Botcazou
2008-03-04  2:38                         ` Robert Dewar
2008-03-03 18:36                     ` Ian Lance Taylor
2008-03-02 11:29                   ` Robert Dewar
2008-03-02 11:36                   ` Richard Kenner
2008-03-02 14:24                   ` Frank Ch. Eigler
2008-03-02 14:31                     ` Robert Dewar
2008-03-02 15:14                       ` Frank Ch. Eigler
2008-03-02 15:21                         ` Robert Dewar
2008-03-02 15:48                           ` Frank Ch. Eigler
2008-03-02 16:08                             ` Robert Dewar
2008-03-02 15:22                         ` Robert Dewar
2008-03-01 19:58               ` Florian Weimer
2008-03-01 20:04                 ` Florian Weimer
2008-03-01 20:12                 ` Robert Dewar
2008-03-01 21:25                   ` Florian Weimer
2008-03-01 21:45                     ` Robert Dewar
2008-03-01 12:31       ` Richard Guenther
2008-03-01 14:00         ` Paolo Bonzini
2008-03-02 13:00         ` Joseph S. Myers
2008-03-02 13:03           ` Richard Guenther
2008-03-05 22:46     ` Ken Raeburn
2008-03-01  0:16   ` David Daney
2008-03-01  2:08     ` Robert Dewar
2008-03-01  6:54   ` Tom Tromey
2008-03-01  0:12 ` Joseph S. Myers
2008-03-01  0:23   ` Richard Guenther
2008-03-01  0:49     ` Joseph S. Myers
2008-03-01  1:57 ` Robert Dewar
2008-03-01 12:33   ` Richard Guenther
2008-03-01 13:08     ` Robert Dewar
     [not found]   ` <fqbn6k$d5j$1@ger.gmane.org>
2008-03-01 13:58     ` Robert Dewar
2008-03-01 14:00       ` Richard Guenther
2008-03-03 22:53       ` Eric Botcazou
2008-03-04  2:39         ` Robert Dewar
2008-03-01 22:16 FX Coudert
2008-03-01 22:31 ` Robert Dewar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=47C96481.2050003@adacore.com \
    --to=dewar@adacore.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=gcc@gcc.gnu.org \
    --cc=joseph@codesourcery.com \
    --cc=kenner@vlsi1.ultra.nyu.edu \
    --cc=mark@codesourcery.com \
    --cc=rguenther@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).