From e0748030863e158ced48802ea42b27e5ec26995f Mon Sep 17 00:00:00 2001 From: Martin Sebor Date: Tue, 19 Mar 2019 18:35:42 +0000 Subject: [PATCH] PR tree-optimization/89644 - false-positive -Warray-bounds on strncpy with unterminated array gcc/ChangeLog: * tree-ssa-strlen.c (handle_builtin_stxncpy): Use full_string_p rather than endptr as an indicator of nul-termination. From-SVN: r269809 --- gcc/ChangeLog | 4 ++++ gcc/tree-ssa-strlen.c | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index fe1f0640e7f..991f019bae4 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,9 @@ 2019-03-19 Martin Sebor + PR tree-optimization/89644 + * tree-ssa-strlen.c (handle_builtin_stxncpy): Use full_string_p + rather than endptr as an indicator of nul-termination. + PR tree-optimization/89644 * tree-ssa-strlen.c (handle_builtin_stxncpy): Consider unterminated arrays in determining sequence sizes in strncpy and stpncpy. diff --git a/gcc/tree-ssa-strlen.c b/gcc/tree-ssa-strlen.c index cf0f70d9d7f..a2dc9c7b102 100644 --- a/gcc/tree-ssa-strlen.c +++ b/gcc/tree-ssa-strlen.c @@ -2210,7 +2210,7 @@ handle_builtin_stxncpy (built_in_function, gimple_stmt_iterator *gsi) if it is known to be nul-terminated. */ if (sidst->nonzero_chars) { - if (sidst->endptr) + if (sidst->full_string_p) { /* String is known to be nul-terminated. */ tree type = TREE_TYPE (sidst->nonzero_chars); @@ -2236,7 +2236,7 @@ handle_builtin_stxncpy (built_in_function, gimple_stmt_iterator *gsi) nul if its known to be nul-terminated. */ if (sisrc->nonzero_chars) { - if (sisrc->endptr) + if (sisrc->full_string_p) { tree type = TREE_TYPE (sisrc->nonzero_chars); srcsize = fold_build2 (PLUS_EXPR, type, sisrc->nonzero_chars, -- 2.30.2