Oddbean new post about | logout
 Ok I see thanks. So, my security code review eyes would want to make a comment on this style and say that declaration should go with assignment.

Because what can happen is that the default assignment is sometimes used mistakenly and results in undefined behavior.

Obviously not an issue if you follow up with the assignments as you did, but just stating an observation. 
 True but I think even -Wall -Werror on all the compilers I've worked with whine about use before assignment. 

If you have a function with 40+ lines it's easy to miss where a variable may have been declared. I use unconditional jumps often, so I like to see where variables are declared incase I need to do something with them. 

If my variables are declared immediately, I always know they are accessible no matter where I jump to in the function. 

But I definitely get the UB of default values. I try to assign variables as the first statement's if possible, and manually assign default/failing values for this reason.  
 Yeah, -wall -werror fixes many problems. 
 Actually when using Visual Studio the intellisense even freaks out with accessing structure members after declaration (before assignment) which is proper behavior in C but I guess frowned upon in C++