On 10/28/19 2:29 PM, Martin Sebor wrote:
> A recent enhancement to take advantage of non-constant strlen
> results constrained to a known range interacts badly with
> the nul-over-nul optimization.  The optimization eliminates
> nul stores that overwrite the exiting terminating nul of
> the destination string.  This interaction causes the nul
> store to be eliminated in subset of cases when it shouldn't
> be.
> 
> The attached patch fixes the bug by avoiding the optimization
> for such destinations.  It also adjusts the comment that
> describes the function with the bug to make its return value
> clearer.
> 
> Tested on x86_64-linux.
> 
> Martin
> 
> gcc-92226.diff
> 
> PR tree-optimization/92226 - live nul char store to array eliminated
> 
> gcc/testsuite/ChangeLog:
> 
>       PR tree-optimization/92226
>       * gcc.dg/strlenopt-88.c: New test.
> 
> gcc/ChangeLog:
> 
>       PR tree-optimization/92226
>       * tree-ssa-strlen.c (compare_nonzero_chars): Return -1 also when
>       the offset is in the open range outlined by SI's length.
> 

OK
jeff

Reply via email to