int x; != int x=0;

Because it's in the loop definition. It dies at the } with most compilers.

(As I mentioned before, 'volatile' doesn't make a difference to lifetime but makes no sense for local variables like this.)