variable in for-loop may not be redeclared in this scope

Problem : 

Intel Compiler fails to compile the following test case

void test()
{
for (int i=0; i < 1000; i++)
{
for (int i=0; i < 1000; i++); // if this is removed MSVC++ 2005 and 2008 give an error
int i;
// ...
}
}

Environment : 

 Windows, MSVC

Root Cause : 

  There are two problems

1>The problem is intel compiler generated two different variable (bug same name i) with same scope number.

2> Not allowing declaration in loop scope to confilct with associated condition-scope and for-init-scope declarations when a for loop previously appeared in the loop scope.



Resolution : 


This issue is resolved in the latest update for the Intel C++ compiler version 11.1

标签:
如需更全面地了解编译器优化,请参阅优化注意事项