public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Gabriel Dos Reis <gdr@integrable-solutions.net>
To: Joe Buck <Joe.Buck@synopsys.COM>
Cc: Paul Schlie <schlie@comcast.net>, gcc@gcc.gnu.org
Subject: Re: Should GCC publish a general rule/warning due to it's default presumption of undefined signed integer overflow semantics?
Date: Fri, 01 Jul 2005 00:49:00 -0000	[thread overview]
Message-ID: <m3irzv5p1r.fsf@uniton.integrable-solutions.net> (raw)
In-Reply-To: <20050630232531.GA11010@synopsys.com>

Joe Buck <Joe.Buck@synopsys.COM> writes:

| On Fri, Jul 01, 2005 at 12:25:58AM +0200, Gabriel Dos Reis wrote:
| > Joe Buck <Joe.Buck@synopsys.COM> writes:
| > 
| > [...]
| > 
| > | Given your biases, you might be happier with Java as a language (than C or
| > | C++).  The Java language designers decided to strictly define many cases
| > | that are not defined in C (example: the order side effects is always
| > | strictly left to right, floating point is always IEEE, etc., integer
| > | overflow wraps around).  There is a performance penalty for this, but
| > | given the "write once, run everywhere" goal it was felt that it's worth
| > | paying this price.
| > 
| > Well, in the case of C++ I can say that the designer and original
| > implementor of C++ is quite amazed as to how people interpret
| > "undefined behaviour" in this thread. 
| 
| Really?  You've talked to Stroustrup?

I work with him on daily basis, and as a matter of fact we've discussed
the heart of this topic of this thread yesterday over lunch.  But, as
much as I hate argument by authority I could not let this discussion
goes on the slope it is taking without saying what I understood from
discussion with him on the topic.  It wasn't meant as a proof.  Just a
data point.  Of course, it is far preferable he speaks for himself but
it is hard to have him take part of a debate where extreme abstract
arguments are more dominant than balance between two apparant
conflicting goals. And that is, I guess, a wise thing to do just as
core developers like RTH may have a say on this very issue :-) 

| Can you be more specific?

yes, see below.

| (If you're talking about the regularly repeated claim that "undefined
| behavior" means the compiler can delete all your files, hack your bank
| account, and send all your money to the GCC team, well, that's just
| hyperbole not to be taken seriously).

as you may correctly guess he is familiar with those rethorical figures. 

| > I don't think he would suggest
| > that people go to use Java instead.
| 
| Are you claiming that Stroustrup would want to sacrifice loop optimization
| to make Paul happy?

No, I'm not claiming that.  But, on the other hand he does not believe
engineering decisions for useful compilers should be primarily based on
SPEC numbers for example, or primarily driven by the best
optimizations without some considerations on the impacts and
"practices" and expectations.  And he is not claiming it is easy :-)

What I'm claiming is that he thinks "undefined behaviour" in the
standard should not be taken as meaning "go to hell" (or punishment to
borrow words from you) or absolute liberty for compiler writers to do
just about everything that is imaginable, regardless of expectations.
In other words, it is a question of balance.  As, an example, he
illustrated the issue with the story -- quickly classified as "legend" by
Robert Dewar -- about the best C optimizing compilers that miscompiled
the Unix kernel that nobody wanted to use in practice (even if it
would blow up any other competing compiler) and the company
running out of business.  (Interestingly, it was also predictated that
Robert would react ;-))

| Undefined behavior doesn't mean that we should attempt to arbitrarily
| punish those who cross the line; that's why I don't think forcing integer
| overflows to trap (at least by default) is a good idea.  In many cases,
| "assume no overflow, but don't trap" can produce a better result than
| "assume wrap" does, as in the example I gave before.

Yes, I understand.

I just don't think the answer would be to tell Paul to go to Java,
even though that would have the side effect of closing the already
long discussion :-)  Correctness and efficiency is important to us.
GCC is of great interest to us too.

-- Gaby

  reply	other threads:[~2005-07-01  0:49 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-30 19:15 Paul Schlie
2005-06-30 20:08 ` Paul Schlie
2005-06-30 22:06 ` Joe Buck
2005-06-30 22:26   ` Gabriel Dos Reis
2005-06-30 23:25     ` Joe Buck
2005-07-01  0:49       ` Gabriel Dos Reis [this message]
2005-07-01  1:03         ` Andrew Pinski
2005-07-01  1:23           ` Gabriel Dos Reis
2005-07-01  1:25           ` Joe Buck
2005-07-01  1:40             ` Gabriel Dos Reis
2005-07-01  3:16               ` Daniel Berlin
2005-07-01  4:07                 ` Gabriel Dos Reis
2005-07-01  4:15                   ` Andrew Pinski
2005-07-01  4:58                     ` Gabriel Dos Reis
2005-07-01  4:53                       ` Andrew Pinski
2005-07-01  5:02                         ` Gabriel Dos Reis
2005-07-02 16:51                   ` Robert Dewar
2005-07-02 19:07                     ` Gabriel Dos Reis
2005-07-02 23:15                       ` Robert Dewar
2005-07-02 23:28                         ` Joe Buck
2005-07-03  0:20                           ` Gabriel Dos Reis
2005-07-03  0:16                         ` Gabriel Dos Reis
2005-07-02 16:47           ` Robert Dewar
2005-07-02 16:45         ` Robert Dewar
2005-07-01  1:04       ` Paul Schlie
2005-07-02 16:48         ` Robert Dewar
2005-07-01  1:35       ` Paul Schlie

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=m3irzv5p1r.fsf@uniton.integrable-solutions.net \
    --to=gdr@integrable-solutions.net \
    --cc=Joe.Buck@synopsys.COM \
    --cc=gcc@gcc.gnu.org \
    --cc=schlie@comcast.net \
    /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).