Assert false positive with TI armcl compiler


#include <assert.h>
void test_assert(uint32_t * 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 :
  • Which rule?
  • 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

Hi Anatoly.

Thanks for reporting this issue. This is indeed a false positive and I can reproduce it using Compiler Explorer, for instance.

In this case, the analyzer fails to recognize that _assert is noreturn in case _expr is equal to 0.

I have created a respective ticket. You can track progress on this FP using [CPP-4524] - Jira.

Thanks for reporting this, again.


1 Like

Thank you

1 Like