This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] avoid assuming strncat/strncpy don't change length of source string (PR 83075)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Martin Sebor <msebor at gmail dot com>
- Cc: Gcc Patch List <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 6 Dec 2017 17:30:53 +0100
- Subject: Re: [PATCH] avoid assuming strncat/strncpy don't change length of source string (PR 83075)
- Authentication-results: sourceware.org; auth=none
- References: <38594ab4-39c8-5018-28de-05927cb3bb4b@gmail.com> <20171120193925.GL14653@tucnak> <16c316bd-4cd7-5bcf-a839-203e1a546bd3@gmail.com> <20171120215616.GS14653@tucnak> <e70ae12e-a720-105c-e9e1-12714ce7efe7@gmail.com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Wed, Dec 06, 2017 at 09:20:15AM -0700, Martin Sebor wrote:
> Attached is a patch with the comment updated/simplified.
> The tests do the job they need to do today so I just removed
> the useless attribute but otherwise left them unchanged. If
> you would like to enhance them in some way please feel free.
Ok for trunk, with a minor nit. I'll tweak the tests incrementally
when it is in.
> --- gcc/tree-ssa-strlen.c (revision 255369)
> +++ gcc/tree-ssa-strlen.c (working copy)
> @@ -1941,10 +1941,9 @@ handle_builtin_stxncpy (built_in_function, gimple_
> int sidx = get_stridx (src);
> strinfo *sisrc = sidx > 0 ? get_strinfo (sidx) : NULL;
>
> - /* Strncpy() et al. cannot modify the source string. Prevent the rest
> - of the pass from invalidating the strinfo data. */
> - if (sisrc)
> - sisrc->dont_invalidate = true;
> + /* Strncat() and strncpy() can modify the source string by writing
Lower case strncat, the function isn't Strncat, whether we are beginning the
sentence or not doesn't matter.
Jakub