
On Fri, Sep 30, 2011 at 12:08 PM, Andrew Sutton
There's nothing in the standard to say that an uninitialized variable must be equal to itself.
Especially since the standard states that the only defined operation on a singular iterator is ... assignment.
Again, I'm not talking about the standard. I'm talking about basic expectations.
If your basic expectations do not take the standard into account then your expectations may lead you to Undefined-Behavior-Land.
If a clever compiler computed the lifespan of all memory usage, is there anything in the standard which would keep it from using the memory of Singular Iterators as temporary storage? Or randomly bit-twiddling the bits in them while they are Singular?
I think any argument that starts with the phrase "If a clever..." is automatically suspect. There are lots of clever things that might be done, but I wonder at what cost. Would you trust your hypothetical compiler to get lifetime right? Do you really want this compiler to modify values behind your back?
Optimizations are clever, and used to be viewed with suspicion.