public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "mpaton at swbell dot net" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/53073] [4.8 Regression] 464.h264ref in SPEC CPU 2006 miscompiled
Date: Tue, 15 Jan 2013 20:01:00 -0000	[thread overview]
Message-ID: <bug-53073-4-787TnoZ7b8@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-53073-4@http.gcc.gnu.org/bugzilla/>


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53073

--- Comment #8 from Michael Paton <mpaton at swbell dot net> 2013-01-15 20:01:04 UTC ---
Hopefully it's correct to reply to the mailing list rather than to bugzilla.
I've tried to find definitive guidance on that and failed.

Thanks for your informative reply asserting C99 non compliance. My assertion on
validity was C89 based, but let's use yours and move on.

I accept that the source code in #c2 is invalid C99 code, and that undefined
behavior may be the result.

However, I will still argue that undefined behavior should be a diagnostic, or
a
lack of an optimizing transformation. If the compiler is to be silent on
discovering this invalid C code, I do not believe it should go on to produce
code that runs until it starts executing an infinite loop.

While that may be allowed by ISO C99, I have a hard time believing that it is
useful to the users of gcc, or indeed intended by its contributors. This
invalid
code compiles and executes with -O0, yet generates bad assembly code ending in
an infinite loop with -O2. I think this is indicative of a bug in gcc 4.8.0. As
to whether such a bug might influence valid code, I cannot say.

Michael Paton

On 1/15/2013 11:56 AM, jakub at gcc dot gnu.org wrote:
> 
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53073
> 
> Jakub Jelinek <jakub at gcc dot gnu.org> changed:
> 
>            What    |Removed                     |Added
> ----------------------------------------------------------------------------
>                  CC|                            |jakub at gcc dot gnu.org
> 
> --- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> 2013-01-15 17:56:05 UTC ---
> You're wrong, the code in #c2 is not valid C.
> ISO C99 6.5.2.1 says that d[++k] is equivalent to:
>   (*((d)+(++k)))
> and ++k in the last iteration is 16, so it is
>   (*(d+16))
> and then 6.5.6/8 (last sentence) applies:
> "If the result points one past the last element of the array object, it
> shall not be used as the operand of a unary * operator that is evaluated."
> So, if you ever enter this loop, you'll invoke undefined behavior and anything
> can happen.
>


  parent reply	other threads:[~2013-01-15 20:01 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-22 17:11 [Bug middle-end/53073] New: " hjl.tools at gmail dot com
2012-04-23  9:21 ` [Bug middle-end/53073] " rguenth at gcc dot gnu.org
2012-04-23 11:30 ` rguenth at gcc dot gnu.org
2012-04-23 11:44 ` rguenth at gcc dot gnu.org
2012-08-21  6:28 ` venkataramanan.kumar at amd dot com
2012-11-08 10:42 ` pinskia at gcc dot gnu.org
2013-01-15 17:02 ` mpaton at swbell dot net
2013-01-15 17:56 ` jakub at gcc dot gnu.org
2013-01-15 20:01 ` mpaton at swbell dot net [this message]
2013-01-28 18:51 ` sje at gcc dot gnu.org
2013-01-29  9:11 ` rguenther at suse dot de
2013-01-31  9:01 ` rguenth at gcc dot gnu.org
2013-01-31  9:29 ` jakub at gcc dot gnu.org

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=bug-53073-4-787TnoZ7b8@http.gcc.gnu.org/bugzilla/ \
    --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).