scoping issue | |
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] | |
This strikes me as a bug. What do you think? It seems the first program should get the same error as the second?
$ cat t.cpp
#include <iostream>
using namespace std;
main()
{
for (int i = 0; i < 5; i++) {
cout << i << endl;
double i = 10.0;
cout << i << endl;
}
}
$ g++ t.cpp
$ a.out
0
10
1
10
2
10
3
10
4
10
$ cat t.cpp
#include <iostream>
using namespace std;
main()
{
int i = 0;
cout << i << endl;
double i = 10.0;
cout << i << endl;
}
$ g++ t.cpp
t.cpp: In function `int main()':
t.cpp:9: conflicting types for `double i'
t.cpp:7: previous declaration as `int i'
$ g++ -v
Reading specs from /usr/local/gcc-3.2.3/bin/../lib/gcc-lib/i686-pc-linux-gnu/3.2.3/specs
Configured with: ./configure --prefix=/usr/local/gcc/gcc-3.2.3
Thread model: posix
gcc version 3.2.3
$ uname -a
Linux zolataylor 2.6.5-7.282-bigsmp #1 SMP Tue Aug 29 10:40:40 UTC 2006 i686 athlon i386 GNU/Linux
$ cat /etc/issue
Welcome to SUSE LINUX Enterprise Server 9 (i586) - Kernel \r (\l).
Jay Haynberg
[Linux C Programming] [C Programming] [Kernel List] [eCos] [Fedora Development] [Fedora Announce] [Autoconf] [The DWARVES Debugging Tools] [Yosemite Campsites] [Yosemite News] [Linux GCC] [C++ How to Program]