4 ms·
The compiler detecting uninitialized use catches a lot of real bugs. A compromise there would be to define it to be initialized to zero, but leave uninitialize
by nullc 10y ago
The compiler detecting uninitialized use catches a lot of real bugs.
A compromise there would be to define it to be initialized to zero, but leave uninitialized use still defined as an error in the program (just not one optimizers can exploit.).
Unfortunately the impact on optimization is also a consideration too.
- braveo 10y agoIn languages that allow you to do things like set the value of enumerations, I always start with 1. The reason being that an uninitialized variable, bad outside input, etc, is more likely to get caught as bad input rather than whatever happens to be in slot 0.