On 08/13/2018 09:21 PM, Martin Sebor wrote:
> [PATCH 2/6] detect unterminated const arrays in strlen calls (PR 86552)
> 
> The attached changes implement the detection of past-the-end reads
> by strlen due to unterminated arguments.
> 
> gcc-86552-2.diff
> 
> 
> PR tree-optimization/86552 - missing warning for reading past the end
> 
> gcc/ChangeLog:
> 
>       * builtins.c (warn_string_no_nul): New function.
>       (expand_builtin_strlen): Warn for unterminated arrays.
>       (fold_builtin_strlen): Add argument.  Warn for unterminated arrays.
>       (fold_builtin_1): Adjust call to fold_builtin_strlen.
>       * builtins.h (warn_string_no_nul): New function.
> 
> gcc/testsuite/ChangeLog:
> 
>       * gcc.dg/warn-strlen-no-nul.c: New test.
So this has a dependency on parts of the 1/6 patch that haven't been
committed yet.

Ignoring that for the moment (since I have those parts in my tree :-)...

There are minor API changes to functions we need to use.  Those are
trivially fixed up.

With that taken care of I get one XPASS from the new test:


> +T (v0 ? &b[3][v0] : &b[3][v1]);   /* { dg-warning "nul" "bug" { xfail *-*-* 
> } }  */
I haven't dug into why this now passes.  It could well be the various
refinements we've made over the last couple weeks.

Given that I've got the patch in my tree I'll take care of posting the
final version of the patch and committing it once I've committed the
prereqs.

Jeff

Reply via email to