[cfe-dev] ISO C3X proposal: nonnull qualifier

Alejandro Colomar (man-pages) via cfe-dev cfe-dev at lists.llvm.org
Wed Dec 1 16:27:12 PST 2021


Hi David,

Macros can also produce code that may introduce NULL checks for nonnull
pointers, and these will be trickier, since there's no discarding of the
qualifier, so... maybe a warning is more difficult to get right.  But
since the optimization is not dangerous if the rest of the code
correctly propagates the _Nonnull-ness of pointers, that shouldn't be a
problem.

If a function (or a block) uses a _Nonnull pointer, then the compiler
can optimize as much as it want there.  It's at the point of assigning
that pointer (normally at function boundaries) where the danger is.  If
you make it impossible to assign a nullable to a nonnull (with the
exception of a preceeding NULL check), then the whole chain is safe.

However, I'd like to do many more tests before coming with a revision of
my proposal.

Cheers,
Alex


More information about the cfe-dev mailing list