The folding of built-in functions does not always yield results with
the correct return type, causing excess warnings (errors with -pedantic-errors).

char *strchr(const char *, int);
char *strrchr(const char *, int);
char *index(const char *, int);
char *rindex(const char *, int);
char *strpbrk(const char *, const char *);
char *strstr(const char *, const char *);
char *p;
void
f (void)
{
  p = strchr(__func__, 'f');
  p = strrchr(__func__, 'f');
  p = index(__func__, 'f');
  p = rindex(__func__, 'f');
  p = strpbrk(__func__, "f");
  p = strstr(__func__, "f");
}

should compile with no diagnostics, but instead each assignment
has "assignment discards qualifiers from pointer target type"
because optimizing the built-in function has wrongly changed the
return type to "const char *" instead of "char *".  This is a regression
in 4.0.

-- 
           Summary: built-in folding causes excess diagnostics
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Keywords: rejects-valid, diagnostic
          Severity: normal
          Priority: P2
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jsm28 at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19967

Reply via email to