https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128170
liu zhenyu <lzy20000419 at outlook dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |wrong-code
Known to work| |7.5.0
Known to fail| |10.5.0, 11.4.0, 12.5.0,
| |13.4.0, 14.2.0, 15.3.0,
| |16.2.0, 17.0, 8.1.0, 9.5.0
--- Comment #1 from liu zhenyu <lzy20000419 at outlook dot com> ---
gcc/tree-ssa-strlen.cc (trunk): handle_builtin_strlen installs the result of
strlen (b + 2) as the length of that string and calls adjust_related_strinfos
(:2343), which updates the related string b to n + 2 and sets dont_invalidate
on b (:1663). strlen has no VDEF, so maybe_invalidate does not run for that
statement and the flag is never cleared. At *q = 0, maybe_invalidate finds
dont_invalidate still set on b, clears it and skips the clobber check, so only
the b + 2 entry is invalidated ("statement may clobber object _1" in
-fdump-tree-strlen1-details). An unrelated store between the strlen and *q = 0
hides the bug, because that store's maybe_invalidate clears the flag.
Suggested fix: only set dont_invalidate when the current statement has a VDEF,
or clear the dont_invalidate flags after every statement, not only after
statements with a VDEF.