Whether its really syntactically illegal I'm not sure (it would definitly be valid inside the method). However, as you suggest, the is a semantic problem and the compiler should issue a warning as i
was used without initialization. IMO the C/C++ compiler does not generally warn of such thing however (Java for instance would give an error), though you might turn on such warning by adding -Wall
parameter to gcc.