News for hackers. Stuff that matters.
Re:Why Not Just Do Simple C++ RAII in C? by adrianN on Thursday May 23, 2024 @02:23AM (#40451136)
I suppose there are ways to make the undefined behavior defined that preserve memory unsafety, so you’re technically correct. In practice one would probably require safe crashes for OOB access etc.
Re:Why Not Just Do Simple C++ RAII in C? by actionfromafar on Thursday May 23, 2024 @05:13AM (#40452381)
I can give an example on how to remove all undefined behaviour and preserve memory unsafety. First, we decide that all compilers compile to a fixed instruction set running on a CPU with a fixed memory model. Just pick one of the existing ones, like a 68000 or a 80486DX. Then, we decide that all unitialized memory is actually 0, always, from the operating system and the allocator. That should go pretty far or am I missing something?