[Bug middle-end/62029] Requesting new warning: missing const-qualifier

2021-12-18 Thread egallager at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62029

Eric Gallager  changed:

   What|Removed |Added

 Blocks||87403
 CC||egallager at gcc dot gnu.org

--- Comment #2 from Eric Gallager  ---
Hm, I thought there was another similar bug requesting a -Wsuggest-const, but I
can't seem to find it right now... (no, bug 80711 under "See Also" isn't it; I
was thinking of a general-purpose const-suggestions request...)


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87403
[Bug 87403] [Meta-bug] Issues that suggest a new warning

[Bug middle-end/62029] Requesting new warning: missing const-qualifier

2017-07-22 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62029

Martin Sebor  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  ---
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, , 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).