1 |
commit: 3e95a56d5d25f40b0f7cad7801714fe797037fb1 |
2 |
Author: Sergei Trofimovich <slyfox <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sun Oct 21 09:22:51 2018 +0000 |
4 |
Commit: Sergei Trofimovich <slyfox <AT> gentoo <DOT> org> |
5 |
CommitDate: Sun Oct 21 09:22:51 2018 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=3e95a56d |
7 |
|
8 |
8.2.0: fix ICE on strncmp validation |
9 |
|
10 |
Reported-by: Toralf Förster |
11 |
https://bugs.gentoo.org/668044 |
12 |
https://gcc.gnu.org/PR87099 |
13 |
Signed-off-by: Sergei Trofimovich <slyfox <AT> gentoo.org> |
14 |
|
15 |
8.2.0/gentoo/113_all_ICE-on-strncmp-PR87099.patch | 86 +++++++++++++++++++++++ |
16 |
8.2.0/gentoo/README.history | 1 + |
17 |
2 files changed, 87 insertions(+) |
18 |
|
19 |
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 |
20 |
new file mode 100644 |
21 |
index 0000000..7e37b5e |
22 |
--- /dev/null |
23 |
+++ b/8.2.0/gentoo/113_all_ICE-on-strncmp-PR87099.patch |
24 |
@@ -0,0 +1,86 @@ |
25 |
+https://bugs.gentoo.org/668044 |
26 |
+https://gcc.gnu.org/PR87099 |
27 |
+ |
28 |
+From e24ceb4802f0cc1bb9e498af6f5bdd29e556c34b Mon Sep 17 00:00:00 2001 |
29 |
+From: jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> |
30 |
+Date: Tue, 28 Aug 2018 11:43:22 +0000 |
31 |
+Subject: [PATCH] PR middle-end/87099 * calls.c |
32 |
+ (maybe_warn_nonstring_arg): Punt early if warn_stringop_overflow is |
33 |
+ zero. Don't call get_range_strlen on 3rd argument, keep iterating until |
34 |
+ lenrng[1] is INTEGER_CST. Only use lenrng[1] if non-NULL and |
35 |
+ INTEGER_CST. Don't uselessly increment lenrng[0]. |
36 |
+ |
37 |
+ * gcc.dg/pr87099.c: New test. |
38 |
+ |
39 |
+ |
40 |
+git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-8-branch@263917 138bc75d-0d04-0410-961f-82ee72b054a4 |
41 |
+--- |
42 |
+ gcc/calls.c | 12 ++++++++---- |
43 |
+ gcc/testsuite/gcc.dg/pr87099.c | 21 +++++++++++++++++++++ |
44 |
+ 4 files changed, 43 insertions(+), 4 deletions(-) |
45 |
+ create mode 100644 gcc/testsuite/gcc.dg/pr87099.c |
46 |
+ |
47 |
+--- a/gcc/calls.c |
48 |
++++ b/gcc/calls.c |
49 |
+@@ -1627,6 +1627,9 @@ maybe_warn_nonstring_arg (tree fndecl, tree exp) |
50 |
+ if (!fndecl || DECL_BUILT_IN_CLASS (fndecl) != BUILT_IN_NORMAL) |
51 |
+ return; |
52 |
+ |
53 |
++ if (!warn_stringop_overflow) |
54 |
++ return; |
55 |
++ |
56 |
+ bool with_bounds = CALL_WITH_BOUNDS_P (exp); |
57 |
+ |
58 |
+ unsigned nargs = call_expr_nargs (exp); |
59 |
+@@ -1655,7 +1658,10 @@ maybe_warn_nonstring_arg (tree fndecl, tree exp) |
60 |
+ conservatively as the bound for the unbounded function, |
61 |
+ and to adjust the range of the bound of the bounded ones. */ |
62 |
+ unsigned stride = with_bounds ? 2 : 1; |
63 |
+- for (unsigned argno = 0; argno < nargs && !*lenrng; argno += stride) |
64 |
++ for (unsigned argno = 0; |
65 |
++ argno < MIN (nargs, 2 * stride) |
66 |
++ && !(lenrng[1] && TREE_CODE (lenrng[1]) == INTEGER_CST); |
67 |
++ argno += stride) |
68 |
+ { |
69 |
+ tree arg = CALL_EXPR_ARG (exp, argno); |
70 |
+ if (!get_attr_nonstring_decl (arg)) |
71 |
+@@ -1693,11 +1699,9 @@ maybe_warn_nonstring_arg (tree fndecl, tree exp) |
72 |
+ if (bound) |
73 |
+ get_size_range (bound, bndrng); |
74 |
+ |
75 |
+- if (*lenrng) |
76 |
++ if (lenrng[1] && TREE_CODE (lenrng[1]) == INTEGER_CST) |
77 |
+ { |
78 |
+ /* Add one for the nul. */ |
79 |
+- lenrng[0] = const_binop (PLUS_EXPR, TREE_TYPE (lenrng[0]), |
80 |
+- lenrng[0], size_one_node); |
81 |
+ lenrng[1] = const_binop (PLUS_EXPR, TREE_TYPE (lenrng[1]), |
82 |
+ lenrng[1], size_one_node); |
83 |
+ |
84 |
+--- /dev/null |
85 |
++++ b/gcc/testsuite/gcc.dg/pr87099.c |
86 |
+@@ -0,0 +1,21 @@ |
87 |
++/* PR middle-end/87099 */ |
88 |
++/* { dg-do compile } */ |
89 |
++/* { dg-options "-Wstringop-overflow" } */ |
90 |
++ |
91 |
++void bar (char *); |
92 |
++ |
93 |
++int |
94 |
++foo (int n) |
95 |
++{ |
96 |
++ char v[n]; |
97 |
++ bar (v); |
98 |
++ return __builtin_strncmp (&v[1], "aaa", 3); |
99 |
++} |
100 |
++ |
101 |
++int |
102 |
++baz (int n, char *s) |
103 |
++{ |
104 |
++ char v[n]; |
105 |
++ bar (v); |
106 |
++ return __builtin_strncmp (&v[1], s, 3); |
107 |
++} |
108 |
+-- |
109 |
+2.19.1 |
110 |
+ |
111 |
|
112 |
diff --git a/8.2.0/gentoo/README.history b/8.2.0/gentoo/README.history |
113 |
index c046242..6b549db 100644 |
114 |
--- a/8.2.0/gentoo/README.history |
115 |
+++ b/8.2.0/gentoo/README.history |
116 |
@@ -2,6 +2,7 @@ |
117 |
+ 111_all_ubd-hog-PR85704.patch |
118 |
U 105_all_libgfortran-Werror.patch |
119 |
+ 112_all_libstdcxx-no-vtv.patch |
120 |
+ + 113_all_ICE-on-strncmp-PR87099.patch |
121 |
|
122 |
1.4 01 Oct 2018 |
123 |
+ 105_all_libgfortran-Werror.patch |