This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/62029] Requesting new warning: missing const-qualifier
- From: "msebor at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 22 Jul 2017 18:24:32 +0000
- Subject: [Bug middle-end/62029] Requesting new warning: missing const-qualifier
- Auto-submitted: auto-generated
- References: <bug-62029-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62029
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |diagnostic
Status|UNCONFIRMED |NEW
Last reconfirmed| |2017-07-22
CC| |msebor at gcc dot gnu.org
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=80711
Ever confirmed|0 |1
--- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> ---
Confirmed. This enhancement would be especially useful in C++. See also
pr80711 for a related request. It would make sense to consider both of these
together.
In C, one caveat/question specific to this request (pointers) is what to do
about C functions like strchr:
void f (char *p)
{
char *q = strchr (p, '\0');
*q = 'x';
}
or strtol:
void g (char *p)
{
char *q;
strtol (p, &q, 0);
*q = '\0';
}
To avoid false positives on this code the warning would have to handle these
cases specially. That's not difficult to do for functions like strchr that GCC
has intrinsic knowledge of but not for others (like strtol).