[LLVMdev] MS C++ gives error C2371 on this code while (obviously)gcc compiles it fine

Jay Freeman (saurik) saurik at saurik.com
Thu Oct 2 10:34:44 PDT 2008


gcc is correct. According to the ISO specification, the for-init-statement 
is supposed to inject any variable names into the same declarative scope as 
the condition of an equivalent restructuring of the loop in the form of a 
while statement, which in turn fronts the declaration to an extra scope that 
surrounds the /entire/ loop construct. VC++ seems to be scoping the 
variables as if they were /inside/ of the loop and not creating this extra 
scope. Frowny. -J

--------------------------------------------------
From: "Yanko" <yhdezalvarez at gmail.com>
Sent: Thursday, October 02, 2008 8:12 AM
To: <llvmdev at cs.uiuc.edu>
Subject: [LLVMdev] MS C++ gives error C2371 on this code while 
(obviously)gcc compiles it fine

...
> makes the code compilable by MS C++. But as a curiosity (and I really
> don't know the answer because I can barely read C++): Which compiler
> got it right? 




More information about the llvm-dev mailing list