https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95886

--- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Martin Sebor
<mse...@gcc.gnu.org>:

https://gcc.gnu.org/g:e4c9aac98611f63847ef6c57916808d9a2d7abcb

commit r10-8871-ge4c9aac98611f63847ef6c57916808d9a2d7abcb
Author: Martin Sebor <mse...@redhat.com>
Date:   Thu Oct 8 12:35:01 2020 -0600

    Correct handling of constant representations containing embedded nuls
(backport from trunk).

    Resolves:
    PR middle-end/95189 - memcmp being wrongly stripped like strcm
    PR middle-end/95886 - suboptimal memcpy with embedded zero bytes

    gcc/ChangeLog:

            PR middle-end/95189
            PR middle-end/95886
            * builtins.c (inline_expand_builtin_string_cmp): Rename...
            (inline_expand_builtin_bytecmp): ...to this.
            (builtin_memcpy_read_str): Don't expect data to be nul-terminated.
            (expand_builtin_memory_copy_args): Handle object representations
            with embedded nul bytes.
            (expand_builtin_memcmp): Same.
            (expand_builtin_strcmp): Adjust call to naming change.
            (expand_builtin_strncmp): Same.
            * expr.c (string_constant): Create empty strings with nonzero size.
            * fold-const.c (c_getstr): Rename locals and update comments.
            * tree.c (build_string): Accept null pointer argument.
            (build_string_literal): Same.
            * tree.h (build_string): Provide a default.
            (build_string_literal): Same.

    gcc/testsuite/ChangeLog:

            PR middle-end/95189
            PR middle-end/95886
            * gcc.dg/memcmp-pr95189.c: New test.
            * gcc.dg/strncmp-3.c: New test.
            * gcc.target/i386/memcpy-pr95886.c: New test.

Reply via email to