ISO C3X proposal: nonnull qualifier

Yesterday I submitted my paper n3089, “_Optional: a type qualifier to indicate pointer nullability” to the WG14 committee.

Abstract: This paper proposes a new type qualifier for the purpose of adding pointer nullability information to C programs. Its goal is to provide value not only for static analysis and documentation, but also for compilers which report errors based only on existing type-compatibility rules. The syntax and semantics are designed to be as familiar (to C programmers) and ergonomic as possible. In contrast, existing solutions are incompatible, confusing, error-prone, and intrusive.

I have also completed a fully working prototype of my proposed changes in Clang (implementing both simple type-compatibility rules, and static analysis). The stack of my commits (many fixing latent bugs in the existing attempt at path-sensitive analysis of null pointers) is here: ⚙ D142744 Re-analyze functions as top-level

Please try out my prototype if you get the chance. I really like it – especially the fact that pointers to _Optional-qualified types can be checked for undefined behaviour much more strictly, unlike vanilla pointers. That’s a bonus I certainly didn’t expect when I joined this discussion.

For clarity, I started a fresh discussion thread concerning my paper and the associated Clang changes: [RFC] _Optional: a type qualifier to indicate pointer nullability
My initial forum post discusses the necessary changes to Clang in a lot more detail than the WG14 paper does.