A Visual Studio 2010 Bug?

c, c++, visual-studio

Solution

int i=0, x = 10;

You just declared a second `x` variable scoped to the `for` loop.

The outer `x` variable is not affected.

Problem

I think I found a bug in VS2010 (C / C++), but it seems so obvious, I cannot believe it. (in the vein of Select isn't Broken). Please let me know if this is a bug, or if I'm missing something: ``` int main(void) { int x; // Declare a variable x; for(int i=0, x = 10; i<5; ++i) // Initialize X to 10. No way around this. { printf("i is %d\n", i); } if (x == 10) // warning C4700: uninitialized local variable 'x' used { printf("x is ten\n"); } } ```

Original source