Skip to content

Latest commit

 

History

History
27 lines (24 loc) · 1.02 KB

compiler-warning-level-1-c4258.md

File metadata and controls

27 lines (24 loc) · 1.02 KB
description title ms.date f1_keywords helpviewer_keywords ms.assetid
Learn more about: Compiler Warning (level 1) C4258
Compiler Warning (level 1) C4258
11/04/2016
C4258
C4258
bbb75e6d-6693-4e62-8ed3-b006a0ec55e3

Compiler Warning (level 1) C4258

'variable' : definition from the for loop is ignored; the definition from the enclosing scope is used"

Under /Ze and /Zc:forScope, variables defined in a for loop go out of scope after the for loop ends. This warning occurs if a variable with the same name as the loop variable, but defined in the enclosing loop, is used again in the scope containing the for loop. For example:

// C4258.cpp
// compile with: /Zc:forScope /W1
int main()
{
   int i;
   {
      for (int i =0; i < 1; i++)
         ;
      i = 20;   // C4258 i (in for loop) has gone out of scope
   }
}