the same id in the same scope refers to different objects

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

Could anyone tell me if the behavior of the following program is
correct? Or there is an error not detected by GCC?

mao@corvax:~/Desktop$ cat foo.c
#include <stdio.h>

int x = 111;

int main(void)
{     int y = x + 222;
      int x = 555;
      printf("x = %d; y = %d\n", x, y);
      return 0;
}
mao@corvax:~/Desktop$ gcc foo.c
mao@corvax:~/Desktop$ ./a.out
x = 555; y = 333
mao@corvax:~/Desktop$ gcc --version
gcc (Debian 4.7.2-5) 4.7.2


Thank you,

Andrew Makhorin




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux