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

            Bug ID: 84953
           Summary: misleading warning from strpbrk(x,"")
           Product: gcc
           Version: 8.0.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: bernd.edlinger at hotmail dot de
  Target Milestone: ---

The following program prints a misleading warning:

$ cat t1.c
#include <string.h>
char* test(char *p)
{
  p = strpbrk(p, "");
  return p;
}

$ gcc -c t1.c
t1.c: In function ‘test’:
t1.c:4:5: warning: assignment discards ‘const’ qualifier from pointer target
type [-Wdiscarded-qualifiers]
   p = strpbrk(p, "");
     ^


The code _is_ bogus, because strpbrk does not make sense with "" as second
Parameter and strpbrk will always return null.
It is just the warning could be much more helpful if the empty string
constant is diagnosed.

Issue was originally found here: https://github.com/openssl/openssl/pull/5666

Reply via email to