Skip to content

False positive: nonnull applied to non-pointer arguments. #3104

@llvmbot

Description

@llvmbot
Bugzilla Link 2732
Resolution FIXED
Resolved on Nov 07, 2018 00:21
Version unspecified
OS All
Reporter LLVM Bugzilla Contributor
CC @tkremenek

Extended Description

The static analyzer complains if 0 is passed as as numerical argument to a function with attribute((nonnull)). According to both the error message and the GCC function attribute documentation (http://gcc.gnu.org/onlinedocs/gcc-4.0.0/gcc/Function-Attributes.html), nonnull only applies to pointer arguments. Test case:

void Callee(int *ip, _Bool f) attribute((nonnull));

void Caller(_Bool f)
{
int x;
if (f) {}; /* [1] Taking false branch. /
Callee(&x, f); /
[2] Null pointer (f) passed as an argument to a 'nonnull' parameter */
}

The intention here is, of course, that ip must not be null, but f may be either true or false.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions