[cfe-dev] RFC: Enable nonnull and warn_unused_result attributes by default
rjmccall at apple.com
Tue Jun 26 19:00:36 PDT 2012
On Jun 26, 2012, at 2:53 PM, 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?
Maybe you're very disciplined about this, but legally null parameters are pervasive in many C code bases. There is no way we could create such a warning and enable it by default; our users would hate us.
Functions with results that are typically ignored are less common but still quite idiomatic. This warning would be possible, but it'd take a lot of tweaking.
More information about the cfe-dev