public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "joseph at codesourcery dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/45831] 0 = 10 (with -O0, 0 = 0 with -O1, but 10 = 10 expected)
Date: Wed, 29 Sep 2010 19:41:00 -0000 [thread overview]
Message-ID: <20100929194100.LHCB4BatCvPquXSU63ftf7y6luYSfVftEouKgJUaAUs@z> (raw)
In-Reply-To: <bug-45831-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45831
--- Comment #9 from joseph at codesourcery dot com <joseph at codesourcery dot com> 2010-09-29 15:43:02 UTC ---
On Wed, 29 Sep 2010, manu at gcc dot gnu.org wrote:
> Why don't we just not compile programs with evident undefined behaviour? I
> think the standard allows us to do so.
http://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_109.html
A conforming implementation must not fail to translate a strictly
conforming program simply because some possible execution of that
program would result in undefined behavior. Because foo might never be
called, the example given must be successfully translated by a
conforming implementation.
The standard never says explicitly whether particular undefined behavior
is compile-time undefined (a property of the program) or run-time
undefined (a property of a particular path of execution through the
program), so you have to read it carefully to figure this out in each
case, but when it is run-time undefined (as here) the program must be
accepted unless all executions must involve the undefined behavior. I
don't think the cases where the undefined behavior is in main and can be
shown always to occur are sufficiently common (in real code rather than
artificial testcases) to make it worthwhile to give errors specially for
them.
next prev parent reply other threads:[~2010-09-29 15:43 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-29 15:33 [Bug c/45831] New: " MichieldeB at aim dot com
2010-09-29 15:35 ` [Bug c/45831] " schwab@linux-m68k.org
2010-09-29 15:43 ` MichieldeB at aim dot com
2010-09-29 15:44 ` MichieldeB at aim dot com
2010-09-29 15:47 ` MichieldeB at aim dot com
2010-09-29 16:28 ` pinskia at gcc dot gnu.org
2010-09-29 17:04 ` manu at gcc dot gnu.org
2010-09-29 17:04 ` MichieldeB at aim dot com
2010-09-29 17:09 ` manu at gcc dot gnu.org
2010-09-29 19:41 ` joseph at codesourcery dot com [this message]
2010-09-30 13:01 ` MichieldeB at aim dot com
2010-09-30 13:13 ` schwab@linux-m68k.org
2010-09-30 16:42 ` jakub at gcc dot gnu.org
2010-09-30 17:09 ` manu at gcc dot gnu.org
2010-09-30 21:10 ` MichieldeB at aim dot com
2010-09-30 21:19 ` manu at gcc dot gnu.org
2010-09-30 23:02 ` MichieldeB at aim dot com
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=20100929194100.LHCB4BatCvPquXSU63ftf7y6luYSfVftEouKgJUaAUs@z \
--to=gcc-bugzilla@gcc.gnu.org \
--cc=gcc-bugs@gcc.gnu.org \
/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).