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

            Bug ID: 64214
           Summary: no warning for unused global
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: pending
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jg at jguk dot org

gcc (Ubuntu 4.8.2-19ubuntu1) 4.8.2

$ g++ -O -Wunused-variable -Werror -Wall -o main gcc_unused.cpp

compiles ok. I had expected it to report the unused global variable:


bool glob = false;

int main()
{
    return 0;
}

if I make the global "static" gcc does report :

gcc_unused.cpp:3:13: error: ‘glob’ defined but not used
[-Werror=unused-variable]

However, could gcc report even when it is not static?

Thank you for considering this.

Reply via email to