public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/35587] -Warray-bounds does not work at all or does not find all trivial cases, and :works only with -O2 or -O3
Date: Mon, 17 Mar 2008 14:06:00 -0000	[thread overview]
Message-ID: <20080317140558.4710.qmail@sourceware.org> (raw)
In-Reply-To: <bug-35587-9066@http.gcc.gnu.org/bugzilla/>



------- Comment #3 from rguenth at gcc dot gnu dot org  2008-03-17 14:05 -------
Hm, with gcc 4.2 I get

gcc-4.2 -c t.c -O2 -Wall
t.c: In function 'main':
t.c:5: warning: array subscript is below array bounds
t.c:7: warning: array subscript is above array bounds
t.c:8: warning: array subscript is above array bounds
t.c:9: warning: array subscript is above array bounds

(the warning in line 11 is missing as the constant is
propagated and the load from a[15] CSEd - this is a very hard
to fix implementation limit.  You'd fix the case in line 9
and then the issue in line 11 would pop up.)

with 4.3 I indeed see

gcc-4.3 -c t.c -O2 -Wall

(nothing)

because all invalid stores are deleted from the code and the only
used value (a[15]) is propagated from the store a[15] = 0 and thus
replaced by the constant 0.  Again a hard to fix implementation
issue - after all these invalid stores/loads invoke undefined
behavior which is why we just "optimized" them.

IMHO for these very simple cases the frontend should already warn
(even at -O0 and -O1) and not rely on the code surviving until VRP.
(The issue is that we in this way would also warn in dead code regions,
which may be a problem on its own).

Note this is not accepts-invalid as it is only undefined at runtime.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mueller at gcc dot gnu dot
                   |                            |org, rguenth at gcc dot gnu
                   |                            |dot org
           Severity|major                       |enhancement
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
           Keywords|accepts-invalid             |
   Last reconfirmed|0000-00-00 00:00:00         |2008-03-17 14:05:57
               date|                            |


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


  parent reply	other threads:[~2008-03-17 14:06 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-14 17:05 [Bug c/35587] New: -Warray-bounds does not work at all or does not find all trivial cases, and works " karsten_burger at gmx dot de
2008-03-14 17:08 ` [Bug c/35587] " karsten_burger at gmx dot de
2008-03-14 17:09 ` karsten_burger at gmx dot de
2008-03-17 13:16 ` [Bug c/35587] -Warray-bounds does not work at all or does not find all trivial cases, and :works " karsten_burger at gmx dot de
2008-03-17 14:06 ` rguenth at gcc dot gnu dot org [this message]
2008-05-03  9:44 ` nikos42 at gmail dot com
     [not found] <bug-35587-4@http.gcc.gnu.org/bugzilla/>
2010-11-25 11:22 ` manu at gcc dot gnu.org
2010-11-25 11:31 ` manu at gcc dot gnu.org
2010-11-25 11:53 ` redi 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=20080317140558.4710.qmail@sourceware.org \
    --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).