Can you provide examples of UB that could be unspecified behaviour, where UB does anything other than cause harm?
Dereferencing a pointer to memory that doesn't point to a live valid object is undefined behaviour. You couldn't possibly specify what this does without instrumenting every single access to memory, like asan or valgrind does.
As I said, behaviour that could be unspecified rather than undefined.
This is an example of something that cannot be anything other than UB.
https://www.youtube.com/watch?v=yG1OZ69H_-o is a great talk on this
Re:RFC: C++ Buffer Hardening
by staticassertion on Thursday October 06, 2022 @05:02AM
(#33106131)
> C++ does not add runtime overhead to validate that programs are well-formed.
You have succinctly described the problem.
C++ does not add runtime overhead to validate that programs are well-formed.