This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] fix ICE in generic_overlap (PR 84526)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Martin Sebor <msebor at gmail dot com>
- Cc: Richard Sandiford <richard dot sandiford at arm dot com>, Gcc Patch List <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 23 Feb 2018 22:54:57 +0100
- Subject: Re: [PATCH] fix ICE in generic_overlap (PR 84526)
- Authentication-results: sourceware.org; auth=none
- References: <d6101f48-539d-2596-f85f-5281a7c15020@gmail.com> <20180223201302.GJ5867@tucnak> <aef14859-cd7e-406f-5916-fcfb546e5659@gmail.com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Fri, Feb 23, 2018 at 02:46:28PM -0700, Martin Sebor wrote:
> > This doesn't address any of my concerns that it is completely random
> > what {dst,src}ref->base is, apples and oranges; sometimes it is a pointer
> > (e.g. the argument of the function), sometimes the ADDR_EXPR operand,
> > sometimes the base of the reference, sometimes again address (if the
> > base of the reference is MEM_REF). By the lack of consistency in what
> > it is, just deciding on its type whether you take TREE_TYPE or
> > TREE_TYPE (TREE_TYPE ()) of it also gives useless result. You could e.g
> > call the memcpy etc. function with ADDR_EXPR of a VAR_DECL that has pointer
> > type, then if dstref->base is that VAR_DECL, POINTER_TYPE_P (basetype)
> > would be true.
>
> I think I understand what you're saying but this block is only
> used for string functions (not for memcpy), and only as a stopgap
> to avoid false positives. Being limited to (a subset of) string
> functions the case I think you're concerned about, namely calling
> strcpy with a pointer to a pointer, shouldn't come up in valid
> code. It's not bullet-proof but I don't think there is
Can you explain what is invalid on:
char *p;
void
foo (void)
{
if (sizeof (p) < 8)
return;
memcpy (&p, "abcdefg");
strcpy ((char *) &p, (char *) &p + 5);
}
and similar code? Both memcpy and strcpy are defined as char accesses
that can alias anything. If needed tweak it so that you run into this code.
Jakub