public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Joe Buck <Joe.Buck@synopsys.COM>
To: Nicholas Nethercote <njn@cs.utexas.edu>
Cc: gcc@gcc.gnu.org
Subject: Re: Some tests in gcc.c-torture rely on undefined behaviour?
Date: Tue, 12 Jul 2005 16:45:00 -0000	[thread overview]
Message-ID: <20050712164531.GA1213@synopsys.com> (raw)
In-Reply-To: <Pine.LNX.4.63.0507120914490.23582@charco.cs.utexas.edu>

On Tue, Jul 12, 2005 at 09:41:22AM -0500, Nicholas Nethercote wrote:
> I've been looking at the gcc.c-torture tests, it seems some of them rely 
> on undefined behaviour.  For example, 920612-1.c looks like this:
> 
>   f(j)int j;{return++j>0;}
>   main(){if(f((~0U)>>1))abort();exit(0);}

Wow.  It appears that it would be legal for a C compiler to optimize f() to

int f(int j) { return 1;}

since the compiler is entitled to assume that overflow does not occur.

Just the same, I don't think we necessarily want to take advantage of
every degree of freedom the standards give us (at least, not by default).

(Oh, crap; I see a massive thread re-emerging).

  reply	other threads:[~2005-07-12 16:45 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-07-12 14:41 Nicholas Nethercote
2005-07-12 16:45 ` Joe Buck [this message]
2005-07-12 16:47 ` Joseph S. Myers
2005-07-12 18:39   ` Ian Lance Taylor
2005-07-12 18:47     ` Diego Novillo
2005-07-12 18:50       ` Ian Lance Taylor
2005-07-13  3:47   ` Nicholas Nethercote
2005-07-13 19:58 ` 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=20050712164531.GA1213@synopsys.com \
    --to=joe.buck@synopsys.com \
    --cc=gcc@gcc.gnu.org \
    --cc=njn@cs.utexas.edu \
    /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).