public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jan Hubicka <hubicka@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r12-4965] Avoid left shift of negative value in ipa-modref-tree.h
Date: Fri,  5 Nov 2021 22:18:27 +0000 (GMT)	[thread overview]
Message-ID: <20211105221827.577703858421@sourceware.org> (raw)

https://gcc.gnu.org/g:9cc8ca8da90426f625481195a2127a5e86689bcd

commit r12-4965-g9cc8ca8da90426f625481195a2127a5e86689bcd
Author: Jan Hubicka <hubicka@ucw.cz>
Date:   Fri Nov 5 23:17:50 2021 +0100

    Avoid left shift of negative value in ipa-modref-tree.h
    
    gcc/ChangeLog:
    
            PR ipa/103082
            * ipa-modref-tree.h (struct modref_access_node): Avoid left shift
            of negative value

Diff:
---
 gcc/ipa-modref-tree.h | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/gcc/ipa-modref-tree.h b/gcc/ipa-modref-tree.h
index 9976e489697..bc428d193d2 100644
--- a/gcc/ipa-modref-tree.h
+++ b/gcc/ipa-modref-tree.h
@@ -116,8 +116,13 @@ struct GTY(()) modref_access_node
 	       if (!known_le (parm_offset, a.parm_offset)
 		   && !range_info_useful_p ())
 		 return false;
+	       /* We allow negative aoffset_adj here in case
+		  there is an useful range.  This is because adding
+		  a.offset may result in non-ngative offset again.
+		  Ubsan fails on val << LOG_BITS_PER_UNIT where val
+		  is negative.  */
 	       aoffset_adj = (a.parm_offset - parm_offset)
-			     << LOG2_BITS_PER_UNIT;
+			     * BITS_PER_UNIT;
 	    }
 	}
       if (range_info_useful_p ())


                 reply	other threads:[~2021-11-05 22:18 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20211105221827.577703858421@sourceware.org \
    --to=hubicka@gcc.gnu.org \
    --cc=gcc-cvs@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).