This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/25880] New: suggestion: a special warning for discarding the ``const'' qualifier
- From: "roland dot illig at gmx dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 20 Jan 2006 15:59:08 -0000
- Subject: [Bug c/25880] New: suggestion: a special warning for discarding the ``const'' qualifier
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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