9 ms·
That's interesting - I had such thoughts as well, way back after my first experience writing significant quantities of C++ (03 back then) in the industry. And
by int_19h 8y ago
That's interesting - I had such thoughts as well, way back after my first experience writing significant quantities of C++ (03 back then) in the industry.
And yes, I think this would require an interpreter, and some kind of shadow memory as you describe (that keeps track of type and lifetime metadata associated with bytes). In fact, I think it would even have to be multi-level segmented memory, with segment per each object (including subobjects!), to fully enforce rules such as out-of-bounds array access, and comparing pointers to different objects.
It could be an interesting exercise. And if written in a verifiable language, the result could, in theory, be declared the specification for the memory model.