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

Jay Freeman (saurik)
Thu, 02 Oct 2008 17:34:44 -0000

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?