On 12/16/2016 12:08 PM, Jakub Jelinek wrote:
On Fri, Dec 16, 2016 at 07:00:06PM +0000, Joseph Myers wrote:
On Fri, 16 Dec 2016, Martin Sebor wrote:

I don't claim it can't be improved but it seems pretty good as
it is already.  Among the 6 instances it's found in GCC three
look like real bugs.

FWIW it's found at least one real bug in glibc
<https://sourceware.org/bugzilla/show_bug.cgi?id=20978> - that's a case
where strlen is called on a pointer that can never be non-null if the
strlen call is reached.  (I don't know if there are other cases in glibc,
whether genuine bugs or false positives, that would appear later in the
build once that bug is fixed.)

Thanks.  Reduced to something like:
int
foo (const char *name)
{
  if (name)
    return 6;
  return __builtin_strlen (name);
}
This is warned about both with Martin's late warning and my after ccp2
warning version.  We should include it in gcc testsuite.
Agreed.
jeff

Reply via email to