proj-oot-ootUndefinedBehaviorThoughts1

So:

why all the specifics about ARBITRARY_VALUE's comparisons? This is to prevent security checks from succeeding when they shouldn't, eg.:

(do something to produce an i which should always be less than 1000) if i < 1000: then we're good else: insecure situation detected, abort

this sort of thing allows invalid code to cause the implementation to: - produce pointers such that dereferencing those pointers cause a segfault - produce values which are larger than or smaller than any value in the supposed datatype (e.g. signed 32-bit arith can be executed as 64-bit arith, so overflow is just an ordinary 64-bit integer larger than, or smaller than, every int32) - produce the wrong values in the proper datatype (e.g. signed 32-bit arith overflow can wrap)

there are other situations, such as uninitialized memory, where we want just an actual arbitrary value that is in the desired datatype. So maybe rename ARBITRARY_VALUE above to ARBITRARY_SUPERVALUE or something like that.

C has something called 'unspecified' which is different from UB, this might be similar. It's been described as " "unspecified" means "anything and not always the same thing" [1]

Ppl also talk about 'indeterminate values' and 'wobbly values' [2]

and ""undefined behaviour" (as opposed to implementation-defined, or some new incantation such as "unknown result in variable but system is safe")" [3]

---

"In essence, modern C and C++ compilers assume no programmer would dare attempt undefined behavior. A programmer writing a program with a bug? Inconceivable! " -- Russ Cox

---