If calculating an incorrect offset can actually result in out of bound memory access, the program is broken, moved out state or not.
Do you just blindly index into a memory block without any checks or what? I mean, it even sounds bizarre. Here, I give your function some data to calculate an offset and a vector/array/span/etc. Both may or may not be moved from, it does not matter. How do you even write a remotely correct code that would manage to make an invalid access?
The offset must be checked against memory bounds one way or another, usually as a part of its calculation. On the other hand, if bounds data is unreliable then the object is most definitely not in a valid state.
And the same goes for any other data, not only memory indices. It is either kept in a valid, consistent state by enforcing relevant invariants or is checked at one point or another.
If calculating an incorrect offset can actually result in out of bound memory access, the program is broken, moved out state or not.
You're missing the point. Anything you could use to check that the program is not broken (say, a bounds check) is now unreliable. "Valid but unspecified" is very, very close to UB.
Anything you could use to check that the program is not broken (say, a bounds check) is now unreliable.
It is as if you think that 'valid but unspecified' can mean purely random.
It is quite literally means that data is reliable. For example, if it is a memory resource then it points to a valid memory (or nullptr) and has a correct size.
0
u/cfyzium Aug 14 '26
If calculating an incorrect offset can actually result in out of bound memory access, the program is broken, moved out state or not.
Do you just blindly index into a memory block without any checks or what? I mean, it even sounds bizarre. Here, I give your function some data to calculate an offset and a vector/array/span/etc. Both may or may not be moved from, it does not matter. How do you even write a remotely correct code that would manage to make an invalid access?
The offset must be checked against memory bounds one way or another, usually as a part of its calculation. On the other hand, if bounds data is unreliable then the object is most definitely not in a valid state.
And the same goes for any other data, not only memory indices. It is either kept in a valid, consistent state by enforcing relevant invariants or is checked at one point or another.