Comment by i2talics
1 day ago
It's useful whenever you don't know the value of an integer but would like to allocate space for it now, and then fill in the value later. Many have mentioned length-prefixed data, which is a good example. Another use case is static linking. I believe LLVM uses this when generating WASM object files.
I think this is probably the real reason such encodings are considered valid. The webassembly spec is explicit about allowing valid over-wide encodings:
https://webassembly.github.io/spec/core/binary/values.html
Maybe a robust parser would benefit from a strict mode, disallowing over-wide encoding.