News for hackers. Stuff that matters.
Re:Ask HN: Why is there not a memory-safe C? by tacostakohashi on Thursday May 24, 2018 @08:32AM (#17143289)
Yes, there is a less powerful subset of C that is memory safe.

You can use local variables, but no pointer types - no variables with pointer types, no functions that return a pointer type, and don't use the * or & operations which dereference or create a pointer.

Initialize everything - there are compiler warnings to help with that.

Admittedly, this subset of C isn't particularly useful. No dynamic memory, no strings or file i/o since those functions from the standard library take pointers. You could definitely do some arithmetic and return the value from main() in a completely memory-safe manner using this subset, though.

There are no comments on this comment yet.