The current gcc warning for discarded qualifiers cannot be easily understood by
beginners:

$ cat const.c
int main(void)
{
        const char *pcc;
        char *pc;

        pcc = "hello, world";
        pc = pcc;
        return 0;
}

$ gcc -Wall -W const.c 
const.c: In function `main':
const.c:7: warning: assignment discards qualifiers from pointer target type

This warning doesn't give any hint to a programmer not familiar with the ISO
standard's wording. Therefore I suggest to make a special case warning if the
only qualifier that's discarded is ``const''. It would then show up like this:

$ ~/pkg/gcc3/bin/gcc -Wall -W const.c 
const.c: In function `main':
const.c:7: warning: assignment discards ``const'' qualifier from pointer target
type


-- 
           Summary: suggestion: a special warning for discarding the
                    ``const'' qualifier
           Product: gcc
           Version: 3.3.5
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: roland dot illig at gmx dot de
 GCC build triplet: *-*-*
  GCC host triplet: *-*-*
GCC target triplet: *-*-*


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

Reply via email to