public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "solar-gcc at openwall dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/59124] [4.8/4.9/5 Regression] Wrong warnings "array subscript is above array bounds"
Date: Wed, 18 Feb 2015 02:22:00 -0000	[thread overview]
Message-ID: <bug-59124-4-Kfnv1PzX2L@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-59124-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59124

Alexander Peslyak <solar-gcc at openwall dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |solar-gcc at openwall dot com

--- Comment #8 from Alexander Peslyak <solar-gcc at openwall dot com> ---
Here's another testcase:

$ gcc -S -Wall -O2 -funroll-loops testcase.c 
testcase.c: In function 'DES_std_set_key':
testcase.c:14:17: warning: array subscript is above array bounds
[-Warray-bounds]
   while (DES_key[i++]) k += 2;
                 ^

=============== 8< ===============
static int DES_KS_updates;
static char DES_key[16];

void DES_std_set_key(char *key)
{
        int i, j, k, l;

        j = key[0];
        for (k = i = 0; (l = DES_key[i]) && (j = key[i]); i++)
                ;

        if (!j) {
                j = i;
                while (DES_key[i++]) k += 2;
        }

        if (k < j && ++DES_KS_updates) {
        }

        DES_key[0] = key[0];
}
=============== >8 ===============

GCC 4.7.4 and below report no warning, 4.8.0 and 4.9.2 report the warning
above.  Either -O2 -funroll-loops or -O3 result in the warning; simple -O2 does
not.  While i++ could potentially run beyond the end of DES_key[], depending on
what's in DES_key[] and key[], this isn't the case in the program this snippet
is taken from (and simplified), whereas the warning definitively claims "is"
rather than "might be".

For comparison, Dmitry's first testcase (from this bug's description) results
in no warning with -O2 -funroll-loops (but does give the warning to me with
-O3, as reported by Dmitry), whereas his second testcase (from comment 2) also
reports the warning with -O2 -funroll-loops (but not with simple -O2).  I
tested this with 4.9.2.

I hope this is similar enough to add to this bug (same affected versions, one
of the two testcases also affected by -funroll-loops).


  parent reply	other threads:[~2015-02-18  2:22 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-14  0:44 [Bug tree-optimization/59124] New: [4.8 " d.g.gorbachev at gmail dot com
2013-11-14  9:51 ` [Bug tree-optimization/59124] [4.8/4.9 " rguenth at gcc dot gnu.org
2013-11-14 17:56 ` d.g.gorbachev at gmail dot com
2013-11-21 14:39 ` rguenth at gcc dot gnu.org
2014-03-12 14:33 ` jakub at gcc dot gnu.org
2014-05-22  9:03 ` [Bug tree-optimization/59124] [4.8/4.9/4.10 " rguenth at gcc dot gnu.org
2014-12-19 13:25 ` [Bug tree-optimization/59124] [4.8/4.9/5 " jakub at gcc dot gnu.org
2015-01-27  9:50 ` rguenth at gcc dot gnu.org
2015-01-27 10:59 ` rguenth at gcc dot gnu.org
2015-02-18  2:22 ` solar-gcc at openwall dot com [this message]
2015-02-18  4:37 ` solar-gcc at openwall dot com
2015-02-19 14:14 ` rguenth at gcc dot gnu.org
2015-02-24 13:09 ` rguenth at gcc dot gnu.org
2015-04-16 12:14 ` [Bug tree-optimization/59124] [4.8/4.9/5/6 " georgmueller at gmx dot net
2015-05-26 15:34 ` georgmueller at gmx dot net
2015-06-01 23:49 ` daniel at imperfectcode dot com
2015-06-23  8:16 ` rguenth at gcc dot gnu.org
2015-06-26 19:53 ` [Bug tree-optimization/59124] [4.9/5/6 " jakub at gcc dot gnu.org
2015-06-26 20:26 ` jakub at gcc dot gnu.org
2015-09-10 21:04 ` pangbw at gmail dot com
2015-09-11  0:29 ` manu at gcc dot gnu.org
2015-09-11 16:13 ` pangbw at gmail dot com
2015-09-11 16:51 ` manu at gcc dot gnu.org
2015-09-17 18:18 ` pangbw at gmail dot com
2015-09-17 19:02 ` pangbw at gmail dot com
2015-09-18 17:59 ` pangbw at gmail dot com
2015-09-18 18:32 ` manu at gcc dot gnu.org
2015-09-18 19:17 ` manu at gcc dot gnu.org
2015-09-18 21:11 ` pangbw at gmail dot com
2015-09-22 20:06 ` pangbw at gmail dot com
2021-01-05  9:14 ` [Bug tree-optimization/59124] [6 " szotsaki at gmail 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=bug-59124-4-Kfnv1PzX2L@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).