public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Sergei Trofimovich" <slyfox@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/gcc-patches:master commit in: 8.2.0/gentoo/
Date: Sun, 21 Oct 2018 09:24:13 +0000 (UTC)	[thread overview]
Message-ID: <1540113771.3e95a56d5d25f40b0f7cad7801714fe797037fb1.slyfox@gentoo> (raw)

commit:     3e95a56d5d25f40b0f7cad7801714fe797037fb1
Author:     Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
AuthorDate: Sun Oct 21 09:22:51 2018 +0000
Commit:     Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
CommitDate: Sun Oct 21 09:22:51 2018 +0000
URL:        https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=3e95a56d

8.2.0: fix ICE on strncmp validation

Reported-by: Toralf Förster
https://bugs.gentoo.org/668044
https://gcc.gnu.org/PR87099
Signed-off-by: Sergei Trofimovich <slyfox <AT> gentoo.org>

 8.2.0/gentoo/113_all_ICE-on-strncmp-PR87099.patch | 86 +++++++++++++++++++++++
 8.2.0/gentoo/README.history                       |  1 +
 2 files changed, 87 insertions(+)

diff --git a/8.2.0/gentoo/113_all_ICE-on-strncmp-PR87099.patch b/8.2.0/gentoo/113_all_ICE-on-strncmp-PR87099.patch
new file mode 100644
index 0000000..7e37b5e
--- /dev/null
+++ b/8.2.0/gentoo/113_all_ICE-on-strncmp-PR87099.patch
@@ -0,0 +1,86 @@
+https://bugs.gentoo.org/668044
+https://gcc.gnu.org/PR87099
+
+From e24ceb4802f0cc1bb9e498af6f5bdd29e556c34b Mon Sep 17 00:00:00 2001
+From: jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
+Date: Tue, 28 Aug 2018 11:43:22 +0000
+Subject: [PATCH] 	PR middle-end/87099 	* calls.c
+ (maybe_warn_nonstring_arg): Punt early if 	warn_stringop_overflow is
+ zero.  Don't call get_range_strlen 	on 3rd argument, keep iterating until
+ lenrng[1] is INTEGER_CST. 	Only use lenrng[1] if non-NULL and
+ INTEGER_CST.  Don't uselessly 	increment lenrng[0].
+
+	* gcc.dg/pr87099.c: New test.
+
+
+git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-8-branch@263917 138bc75d-0d04-0410-961f-82ee72b054a4
+---
+ gcc/calls.c                    | 12 ++++++++----
+ gcc/testsuite/gcc.dg/pr87099.c | 21 +++++++++++++++++++++
+ 4 files changed, 43 insertions(+), 4 deletions(-)
+ create mode 100644 gcc/testsuite/gcc.dg/pr87099.c
+
+--- a/gcc/calls.c
++++ b/gcc/calls.c
+@@ -1627,6 +1627,9 @@ maybe_warn_nonstring_arg (tree fndecl, tree exp)
+   if (!fndecl || DECL_BUILT_IN_CLASS (fndecl) != BUILT_IN_NORMAL)
+     return;
+ 
++  if (!warn_stringop_overflow)
++    return;
++
+   bool with_bounds = CALL_WITH_BOUNDS_P (exp);
+ 
+   unsigned nargs = call_expr_nargs (exp);
+@@ -1655,7 +1658,10 @@ maybe_warn_nonstring_arg (tree fndecl, tree exp)
+ 	   conservatively as the bound for the unbounded function,
+ 	   and to adjust the range of the bound of the bounded ones.  */
+ 	unsigned stride = with_bounds ? 2 : 1;
+-	for (unsigned argno = 0; argno < nargs && !*lenrng; argno += stride)
++	for (unsigned argno = 0;
++	     argno < MIN (nargs, 2 * stride)
++	     && !(lenrng[1] && TREE_CODE (lenrng[1]) == INTEGER_CST);
++	     argno += stride)
+ 	  {
+ 	    tree arg = CALL_EXPR_ARG (exp, argno);
+ 	    if (!get_attr_nonstring_decl (arg))
+@@ -1693,11 +1699,9 @@ maybe_warn_nonstring_arg (tree fndecl, tree exp)
+   if (bound)
+     get_size_range (bound, bndrng);
+ 
+-  if (*lenrng)
++  if (lenrng[1] && TREE_CODE (lenrng[1]) == INTEGER_CST)
+     {
+       /* Add one for the nul.  */
+-      lenrng[0] = const_binop (PLUS_EXPR, TREE_TYPE (lenrng[0]),
+-			       lenrng[0], size_one_node);
+       lenrng[1] = const_binop (PLUS_EXPR, TREE_TYPE (lenrng[1]),
+ 			       lenrng[1], size_one_node);
+ 
+--- /dev/null
++++ b/gcc/testsuite/gcc.dg/pr87099.c
+@@ -0,0 +1,21 @@
++/* PR middle-end/87099 */
++/* { dg-do compile } */
++/* { dg-options "-Wstringop-overflow" } */
++
++void bar (char *);
++
++int
++foo (int n)
++{
++  char v[n];
++  bar (v);
++  return __builtin_strncmp (&v[1], "aaa", 3);
++}
++
++int
++baz (int n, char *s)
++{
++  char v[n];
++  bar (v);
++  return __builtin_strncmp (&v[1], s, 3);
++}
+-- 
+2.19.1
+

diff --git a/8.2.0/gentoo/README.history b/8.2.0/gentoo/README.history
index c046242..6b549db 100644
--- a/8.2.0/gentoo/README.history
+++ b/8.2.0/gentoo/README.history
@@ -2,6 +2,7 @@
 	+ 111_all_ubd-hog-PR85704.patch
 	U 105_all_libgfortran-Werror.patch
 	+ 112_all_libstdcxx-no-vtv.patch
+	+ 113_all_ICE-on-strncmp-PR87099.patch
 
 1.4		01 Oct 2018
 	+ 105_all_libgfortran-Werror.patch


             reply	other threads:[~2018-10-21  9:24 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-21  9:24 Sergei Trofimovich [this message]
  -- strict thread matches above, loose matches on Subject: below --
2020-01-08 22:42 [gentoo-commits] proj/gcc-patches:master commit in: 8.2.0/gentoo/ Sergei Trofimovich
2019-02-11 21:59 Sergei Trofimovich
2019-02-10 12:12 Sergei Trofimovich
2019-01-29 20:24 Sergei Trofimovich
2018-12-26 19:31 Sergei Trofimovich
2018-12-18 22:38 Sergei Trofimovich
2018-12-10 22:48 Sergei Trofimovich
2018-12-01 13:06 Sergei Trofimovich
2018-11-22 23:55 Sergei Trofimovich
2018-10-27  9:04 Sergei Trofimovich
2018-10-20  9:40 Sergei Trofimovich
2018-10-18 20:40 Sergei Trofimovich
2018-10-08 22:05 Sergei Trofimovich
2018-10-08 22:05 Sergei Trofimovich
2018-10-01  6:41 Sergei Trofimovich
2018-09-30 22:08 Sergei Trofimovich
2018-09-23 20:37 Sergei Trofimovich
2018-09-15 19:30 Sergei Trofimovich
2018-08-12 22:56 Sergei Trofimovich
2018-08-12 20:27 Sergei Trofimovich
2018-08-08  8:37 Sergei Trofimovich
2018-08-08  8:31 Sergei Trofimovich
2018-08-08  8:26 Sergei Trofimovich
2018-08-08  7:58 Sergei Trofimovich

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=1540113771.3e95a56d5d25f40b0f7cad7801714fe797037fb1.slyfox@gentoo \
    --to=slyfox@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.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