[Bug c/78359] New: Redeclaration of global variables is not reported

robert.kollataj at ac dot com.pl gcc-bugzilla@gcc.gnu.org
Tue Nov 15 06:47:00 GMT 2016


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

            Bug ID: 78359
           Summary: Redeclaration of global variables is not reported
           Product: gcc
           Version: 5.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: robert.kollataj at ac dot com.pl
  Target Milestone: ---

The problem concerns GCC compiler for embedded v. 5.2.0. (pure C language)
The compiler does not report redeclaration of global variables. The following
example shows how it happens:

int Counter, Counter, Counter;

int main(void)
{
  Counter++;
  if (Counter > 0)
  {
    ......
  }
}

This code is compiled without errors (I wonder which copy of "Counter" is
really taken into account by the compiler...)

When the "Counter" is declared as local variable, the compiler reports an
error:



int main(void)
{

  int Counter, Counter, Counter;

  Counter++;
  if (Counter > 0)
  {
    ......
  }
}

 error: redeclaration of 'Counter' with no linkage


More information about the Gcc-bugs mailing list