[cfe-dev] RFC: Enable nonnull and warn_unused_result attributes by default

Joerg Sonnenberger joerg at britannica.bec.de
Wed Jun 27 06:52:47 PDT 2012

On Wed, Jun 27, 2012 at 12:53:54AM +0300, Timo Sirainen wrote:
> GCC has "nonnull" and "warn_unused_result" attributes that are really
> great for finding bugs, assuming they're used everywhere. The problem
> is, they would have to be used for >99% of the functions, which makes
> them way too much trouble to be worth it for normal code. So wouldn't
> it be better to just make that the default behavior, and add "null"
> and "nowarn_unused_result" attributes for the few exceptions where the
> opposite behavior is needed?

It's a bad idea. Many lint implementations have allows this since pretty
much forever, it tends to create way more noise than it helps. It is
also very easy to create bogus warn_unused_result attributions. Modern
glibc is a prime example. Pretty much all of stdio allows two different
kinds of error checking -- doing it per function call or once at the end
with ferror. Guess what is broken with glibc...


More information about the cfe-dev mailing list