This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] avoid assuming strncat/strncpy don't change length of source string (PR 83075)


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]