[1/1] Work around array out of bounds warning in mkdeps

Message ID 20191217091436.28946-1-krebbel@linux.ibm.com
State New
Headers show
Series
  • [1/1] Work around array out of bounds warning in mkdeps
Related show

Commit Message

Andreas Krebbel Dec. 17, 2019, 9:14 a.m.
This suppresses an array out of bounds warning in mkdeps.c as proposed
by Martin Sebor in the bugzilla.

array subscript 2 is outside array bounds of ‘const char [2]’

Since this warning does occur during bootstrap it currently breaks
werror builds on IBM Z.

The problem can be reproduced also on x86_64 by changing the inlining
threshold using: --param max-inline-insns-auto=80

Bootstrapped and regression tested on x86_64 and IBM Z.

Ok for mainline?

libcpp/ChangeLog:

2019-12-17  Andreas Krebbel  <krebbel@linux.ibm.com>

	PR tree-optimization/92176
	* mkdeps.c (deps_add_default_target):
---
 libcpp/mkdeps.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

-- 
2.23.0

Comments

Jeff Law Jan. 6, 2020, 5:14 p.m. | #1
On Tue, 2019-12-17 at 10:14 +0100, Andreas Krebbel wrote:
> This suppresses an array out of bounds warning in mkdeps.c as proposed

> by Martin Sebor in the bugzilla.

> 

> array subscript 2 is outside array bounds of ‘const char [2]’

> 

> Since this warning does occur during bootstrap it currently breaks

> werror builds on IBM Z.

> 

> The problem can be reproduced also on x86_64 by changing the inlining

> threshold using: --param max-inline-insns-auto=80

> 

> Bootstrapped and regression tested on x86_64 and IBM Z.

> 

> Ok for mainline?

> 

> libcpp/ChangeLog:

> 

> 2019-12-17  Andreas Krebbel  <krebbel@linux.ibm.com>

> 

> 	PR tree-optimization/92176

> 	* mkdeps.c (deps_add_default_target):

> ---

>  libcpp/mkdeps.c | 2 +-

>  1 file changed, 1 insertion(+), 1 deletion(-)

OK with a fixed ChangeLog entry.

jeff

Patch

diff --git a/libcpp/mkdeps.c b/libcpp/mkdeps.c
index 147aa909be7..d1001e30e19 100644
--- a/libcpp/mkdeps.c
+++ b/libcpp/mkdeps.c
@@ -268,7 +268,7 @@  deps_add_default_target (class mkdeps *d, const char *tgt)
     return;
 
   if (tgt[0] == '\0')
-    deps_add_target (d, "-", 1);
+    d->targets.push (xstrdup ("-"));
   else
     {
 #ifndef TARGET_OBJECT_SUFFIX