[cfe-dev] ISO C3X proposal: nonnull qualifier

Joerg Sonnenberger via cfe-dev cfe-dev at lists.llvm.org
Wed Dec 1 14:24:56 PST 2021


On Wed, Dec 01, 2021 at 10:57:51PM +0100, Alejandro Colomar (man-pages) via cfe-dev wrote:
> (2):  I'm not sure I understand this one.  I also didn't find the LKML
> thread.  My idea is that if the compiler enforces nonnull-ness as it
> does currently with const, it will be possible to guarantee that sanity
> checks are unnecessary, and therefore they can be safely omitted (by the
> user, not the compiler).

The original "bug" boils down to something like this:

   int f(int *p) {
      int x = *p;
      if (!p)
        return -1;
      return x;
   }

GCC sees the *p, and drops the if condition. Replace that with a call to
a function that has a nonnull attribute and you get the same problem.

Joerg


More information about the cfe-dev mailing list