Re: Help needed [Was: Bug#667325: plink: ftbfs with GCC-4.7]
Hi,
On Sun, Apr 22, 2012 at 5:37 PM, Dmitry Nezhevenko <dion@inhex.net> wrote:
> As you can see, there is nested declaration here. It's wrong. Looks like
> this code was working due to some GCC bug. Other compilers forbids this
> too.
To expand/clarify, this is not a "nested declaration", but rather a
redefinition of a variable that was declared in the same scope.
Redefining variables in different scopes is fine. So if i were
declared outside the scope of the for loop, this would be okay (this
is called shadowing).
Apparently, g++ up to 4.6 considered the scope of a variable declared
in a for loop to be the "outer" scope, instead of the "inner"
scope[1][2]. This explains the problem.
[1]: http://gcc.gnu.org/gcc-4.7/porting_to.html
[2]: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=2288
Regards,
Reply to: