I am seeing a false positive assertWithSideEffect warning when an assert contains a function pointer comparison.
Here is sample code based on code from glib-networking:
#include <assert.h> typedef struct { bool field; } st; static bool handshake () { st *priv; priv->field = true; return true; } int main() { bool (*fptr)() = handshake; assert (handshake == fptr); # warning: Assert statement calls a function which may have desired side effects: 'handshake'. [assertWithSideEffect] return 0; }
I don't think a function call is actually being made in this case.
Versions tested: dfcec18902 and 2.21.1 (Arch Linux)
Thanks for reporting, ticket is here: https://trac.cppcheck.net/ticket/14973
Log in to post a comment.
I am seeing a false positive assertWithSideEffect warning when an assert contains a function pointer comparison.
Here is sample code based on code from glib-networking:
I don't think a function call is actually being made in this case.
Versions tested:
dfcec18902 and 2.21.1 (Arch Linux)
Thanks for reporting, ticket is here: https://trac.cppcheck.net/ticket/14973