This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/43894] New: with -std=c++0x, auto and for loop does not play nice when another variable is involved
- From: "ghodechhap at ghodechhap dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 26 Apr 2010 14:23:08 -0000
- Subject: [Bug c++/43894] New: with -std=c++0x, auto and for loop does not play nice when another variable is involved
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------------------------------------------------------------
#include <iostream>
#include <map>
int main()
{
std::map<int,int> dummy;
for(int i=0;i<5;i++) dummy[i*2] = (100-i);
#ifdef BUG
for(auto itr=dummy.begin(),int i=0;itr!=dummy.end();++itr,++i)
std::cout << "i:" << i << std::endl;
#endif
#ifdef WORKAROUND
auto itr=dummy.begin();
for(int i=0;itr!=dummy.end();++itr,++i)
std::cout << "i:" << i << std::endl;
#endif
return 0;
}
------------------------------------------------------------
$ g++ -std=c++0x -DBUG -o auto.bug auto.bug.cpp
auto.bug.cpp: In function ?int main()?:
auto.bug.cpp:10:29: error: expected unqualified-id before ?int?
auto.bug.cpp:10:62: error: name lookup of ?i? changed for ISO ?for? scoping
auto.bug.cpp:10:62: note: (if you use ?-fpermissive? G++ will accept your code)
$ g++ -std=c++0x -DWORKAROUND -o auto.bug auto.bug.cpp
It should have worked the same in both the cases no?
--
Summary: with -std=c++0x, auto and for loop does not play nice
when another variable is involved
Product: gcc
Version: 4.5.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: ghodechhap at ghodechhap dot net
GCC build triplet: x86_64-unknown-linux-gnu
GCC host triplet: x86_64-unknown-linux-gnu
GCC target triplet: x86_64-unknown-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43894