HNHacker News
TopNewBestAskShowJobs

reynmorris

-3 karma · joined June 2, 2024

submissionscomments
reynmorris··on Circle C++ with memory safety
You can assume that the collection doesn't have good coverage, but what I'm saying is the constructs in the C++ language are there to make it have good coverage. Pair this with some Clang sanitation (like banning raw pointers) and you'd have to go out of your way to make it unsafe.
reynmorris··on Circle C++ with memory safety
That is not an issue with the safety of the Vector, it is an issue with the safety of 'int' and raw pointers. If the Vector grows, that pointer points to freed memory.

But yes, in my implementation I have a safe version of int called 'i32' which overrides the & operator and doesn't allow it to return raw pointers.

reynmorris··on Circle C++ with memory safety
It's simple, whether the backing memory is heap or stack, it's bounds checked. And overriding all the operators and only returning safe types prevents many types of undefined behavior.

Of course you can fuck with it enough to make it unsafe, but at that point you know exactly what you're doing

reynmorris··on Circle C++ with memory safety
A lot of coders already do this. My STL replacement has Vector and VectorUnsafe. Vector is checked to the hilt for bounds safety, stack safety, UB safety, etc. and is slower. But if I have a tight loop, I can use VectorUnsafe and just make sure I'm being careful, and it has no checks at all.