4 ms·
> an automated system to convert unsafe C into safe something Can't we just make macros to redefine types as some 'safe' type variant system, and #include "saf
by 0xbadcafebee 4y ago
> an automated system to convert unsafe C into safe something
Can't we just make macros to redefine types as some 'safe' type variant system, and #include "safetypes.h" or something? It's ugly, but searching your source code for 'int a[5]' and replacing it with 'INT(a,5)' might be dumb enough to work.
- friendzis 4y agoStatically allocated/sized arrays are relatively easy. The problem is dynamically allocated/sized arrays coupled with pointer "interface", which supports type casting.
- Animats 4y agoSomething smart enough to convert pointer arithmetic to slice expressions is needed. Most C pointer arithmetic is really just slice access. (Who invented array slices? It was a concept that came along much later than one might have expected.)