Code:
#include <assert.h>
void test_assert(uint32_t * ptr)
{
assert(ptr);
*ptr = 1;
}
The assert code used in armcl TI compiler
(taken from <assert.h> and tested by adding #error 1 in this place to make sure it is the correct one ) :
#define assert(_expr) _assert((_expr) != 0, \
"Assertion failed, (" _STR(_expr) "), file " __FILE__ \
", line " _STR(__LINE__) "\n")
Then tell us:
- What language is this for?
c for TI armcl compiler :
C:/ti/ccs1120/ccs/tools/compiler/ti-cgt-arm_20.2.5.LTS/bin/armcl - Which rule?
c:S2259 - Why do you believe it’s a false-positive/false-negative?
The assert itself trigger the S2259
And the error is we dereference the pointer
- Are you using
SonarCloud?