public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/48267] incorrect signed overflow warning when a pointer cannot possibly overflow
Date: Thu, 24 Mar 2011 12:18:00 -0000	[thread overview]
Message-ID: <bug-48267-4-lAWJW1K7el@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-48267-4@http.gcc.gnu.org/bugzilla/>


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

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2011.03.24 12:14:46
          Component|c                           |middle-end
     Ever Confirmed|0                           |1
      Known to fail|                            |4.5.2, 4.7.0

--- Comment #1 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-03-24 12:14:46 UTC ---
Confirmed.  Happens from

#1  0x00000000007307e7 in fold_undefer_overflow_warnings (issue=1 '\001', 
    stmt=0x7ffff5b373c0, code=2)
    at /space/rguenther/src/svn/trunk/gcc/fold-const.c:281
281       warning_at (locus, OPT_Wstrict_overflow, "%s", warnmsg);
(gdb) 
#2  0x0000000000afdfdf in evaluate_stmt (stmt=0x7ffff5b373c0)
    at /space/rguenther/src/svn/trunk/gcc/tree-ssa-ccp.c:2117
2117          fold_undefer_overflow_warnings (is_constant, stmt, 0);
(gdb)
#3  0x0000000000aff7c5 in visit_cond_stmt (stmt=0x7ffff5b373c0, 
    taken_edge_p=0x7fffffffda48)
    at /space/rguenther/src/svn/trunk/gcc/tree-ssa-ccp.c:2443
2443      val = evaluate_stmt (stmt);
(gdb) 
#4  0x0000000000aff8f8 in ccp_visit_stmt (stmt=0x7ffff5b373c0, 
    taken_edge_p=0x7fffffffda48, output_p=0x7fffffffda40)
    at /space/rguenther/src/svn/trunk/gcc/tree-ssa-ccp.c:2501
2501            return visit_cond_stmt (stmt, taken_edge_p);

(gdb) call debug_gimple_stmt (stmt)
if (p_1 < &head_table[1])

which calls fold_binary with &head_table < &head_table[1] and in the end warns
here:

8688                  if (code != EQ_EXPR
8689                      && code != NE_EXPR
8690                      && bitpos0 != bitpos1
8691                      && (pointer_may_wrap_p (base0, offset0, bitpos0)
8692                          || pointer_may_wrap_p (base1, offset1, bitpos1)))
8693                    fold_overflow_warning (("assuming pointer wraparound
does not "
8694                                            "occur when comparing P +- C1
with "
8695                                            "P +- C2"),
8696                                          
WARN_STRICT_OVERFLOW_CONDITIONAL)

because we call pointer_may_wrap_p with base0 which isn't an address
but an object which is bogus.  It's argument has to depend on
indirect_base in which case we stripped an ADDR_EXPR.


  reply	other threads:[~2011-03-24 12:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-24  8:53 [Bug c/48267] New: " eggert at gnu dot org
2011-03-24 12:18 ` rguenth at gcc dot gnu.org [this message]
2021-09-28  9:09 ` [Bug middle-end/48267] " pinskia 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-48267-4-lAWJW1K7el@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).