public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/108079] New: -Wunused-variable gives misleading duplicate warning for unused static local variable
@ 2022-12-13  4:50 stephenheumann at gmail dot com
  2022-12-13 12:16 ` [Bug c/108079] [10/11/12/13 Regression] " rguenth at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: stephenheumann at gmail dot com @ 2022-12-13  4:50 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 108079
           Summary: -Wunused-variable gives misleading duplicate warning
                    for unused static local variable
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: stephenheumann at gmail dot com
  Target Milestone: ---

For this program:

int main(void) {
        static int x;
}

gcc -Wunused-variable reports:

<source>: In function 'main':
<source>:2:20: warning: unused variable 'x' [-Wunused-variable]
    2 |         static int x;
      |                    ^
<source>: At top level:
<source>:2:20: warning: 'x' defined but not used [-Wunused-variable]

These two warnings are about the same thing, except the second one is
incorrectly labeled "At top level." There should just be one warning, without
"At top level."

C++ does the same thing, except it says "At global scope" instead of "At top
level."

This seems to be a regression that occurred in GCC 6: 5.4 just gives one
warning, but 6.1 also gives the extra one with "At top level."

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

end of thread, other threads:[~2023-07-07 10:44 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-13  4:50 [Bug c/108079] New: -Wunused-variable gives misleading duplicate warning for unused static local variable stephenheumann at gmail dot com
2022-12-13 12:16 ` [Bug c/108079] [10/11/12/13 Regression] " rguenth at gcc dot gnu.org
2022-12-21 14:14 ` jakub at gcc dot gnu.org
2022-12-21 14:40 ` jakub at gcc dot gnu.org
2023-03-10  9:15 ` cvs-commit at gcc dot gnu.org
2023-03-10  9:19 ` [Bug c/108079] [10/11/12 " jakub at gcc dot gnu.org
2023-03-19  5:30 ` cvs-commit at gcc dot gnu.org
2023-03-20 10:30 ` [Bug c/108079] [10/11 " jakub at gcc dot gnu.org
2023-07-07 10:44 ` [Bug c/108079] [11 " rguenth 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).