Doug H
2014-12-21 18:50:15 UTC
int x;
You could pretty much depend on x NOT being 0. It would almost always have some other garbage value.
I've just gotten back into c++ lately, and found that the value IS 0 all of the times that I've tested it.
So it seems like compilers have changed this.
I'm still in the habit of not using a value before I assign it, but now I'm in a situation where I could be losing a lot of performance if I set the values after declaring the variables.
Specifically, something like this:
int x[300][300][300];
...in more than one object, being created regularly.
I'll be wasting a lot of CPU time if i go through this 3-dimensional array setting all those value to 0 if I don't need to.
So, with modern compilers, can I depend on those values all being 0 without having to set them all?