public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/62029] New: Requesting new warning: missing const-qualifier
@ 2014-08-05 23:56 mi+gcc at aldan dot algebra.com
  2021-12-18 11:19 ` [Bug middle-end/62029] " egallager at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: mi+gcc at aldan dot algebra.com @ 2014-08-05 23:56 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62029

            Bug ID: 62029
           Summary: Requesting new warning: missing const-qualifier
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mi+gcc at aldan dot algebra.com

To help facilitate "const-poisoning" of the entire body of C (and C++) code out
there, I'd like to see a new warning, that would fire, when a pointer to any
object in any scope, that could've been marked as "const", is not.

For example:

size_t
mylen(char *string)
{
      if (string == NULL)
         return 0;
      else
         return strlen(string);
}

void
example(struct object *o)
{
      char *text = get_text(o);
      size_t len = mylen(text);
      ....
}

The above code would warn in mylen, because the function's parameter could be
made const. As the developer fixes the low-level function to address the
warning, the higher level callers of these functions (such as example()) will
start warning -- and that will be a beautiful thing...

Some day the warning may even become part of -Wall.


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug middle-end/62029] Requesting new warning: missing const-qualifier
  2014-08-05 23:56 [Bug middle-end/62029] New: Requesting new warning: missing const-qualifier mi+gcc at aldan dot algebra.com
@ 2021-12-18 11:19 ` egallager at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: egallager at gcc dot gnu.org @ 2021-12-18 11:19 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62029

Eric Gallager <egallager at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Blocks|                            |87403
                 CC|                            |egallager at gcc dot gnu.org

--- Comment #2 from Eric Gallager <egallager at gcc dot gnu.org> ---
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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-12-18 11:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-05 23:56 [Bug middle-end/62029] New: Requesting new warning: missing const-qualifier mi+gcc at aldan dot algebra.com
2021-12-18 11:19 ` [Bug middle-end/62029] " egallager at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).