4 ms·
Making out of bounds access on explicitly bound types is an easy memory safety win. The fact the UB is still being used as an excuse to clearly undermine reaso
by olliej 4y ago
Making out of bounds access on explicitly bound types is an easy memory safety win.
The fact the UB is still being used as an excuse to clearly undermine reasonably expected behaviour remains a BS trope, and WG21's continued acceptance of new features and specifications that say perfectly specifiable behaviour is UB instead of unspecified is a continuing source of avoidable security bugs.
It is inexcusable for new features to be added to C++ that have UB in any case other than the undefinable (invalid memory access, etc). Removing the copious unnecessary UB from the existing specs should be a higher priority that many of the new features being proposed.
- saagarjha 4y agoMuch that is UB deserves to be defined. And some that is defined deserves to be UB. Can you make it illegal? Then do not be too eager to deal out behaviors in standardization. I don't actually oppose, in the long run, slowly picking some behaviors and changing them to be standardized. But I do vehemently oppose many of the suggestions that are brought up. The kinds of things that should be moved out of being undefined are things like "you named your function isfoo" and not "you passed NULL to memset".
- olliej 4y ago> And some that is defined deserves to be UB. Can you provide an example of currently specified behaviour that should be UB? To be very clear I am using specification language here. "Unspecified behaviour" is very much not "undefined behaviour".
- flohofwoe 4y agoIt's an LoTR joke: "Many that live deserve death. And some that die deserve life. Can you give it to them? Then do not be too eager to deal out death in judgement"
- mgaunard 4y agoUndefined behaviour is great. I for one will continue to vote in its favour. C++ does not add runtime overhead to validate that programs are well-formed.
- staticassertion 4y ago> C++ does not add runtime overhead to validate that programs are well-formed. You have succinctly described the problem.
- mgaunard 4y agoThat's not a problem, that's a core policy of that language's design. If you want a language that is slow, there are plenty of options.
- olliej 4y agoCan you provide examples of UB that could be unspecified behaviour, where UB does anything other than cause harm?
- mgaunard 4y agoDereferencing 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.
- olliej 4y agoAs I said, behaviour that could be unspecified rather than undefined. This is an example of something that cannot be anything other than UB.
- kllrnohj 4y agohttps://www.youtube.com/watch?v=yG1OZ69H_-o https://www.youtube.com/watch?v=yG1OZ69H_-o is a great talk on this