3 ms·
C could support the concept of nullable vs non-null pointers. Clang even already has this as an extension: https://clang.llvm.org/docs/AttributeReference.html#n
by david2ndaccount 4y ago
C could support the concept of nullable vs non-null pointers. Clang even already has this as an extension: https://clang.llvm.org/docs/AttributeReference.html#nullability-attributes https://clang.llvm.org/docs/AttributeReference.html#nullabil...
There is also an associated nullability sanitizer.
I use this in my own C code all the time and null pointer errors vanish if you faithfully annotate every pointer. There’s also a pragma to make non null pointers the default in a file.
GCC devs would have to be convinced to add this to GCC and then nullability annotations would need to be added to the kernel. You can then do static analysis/compile error if you do an unguarded check of a nullable pointer.