Failed assertion statement
This defect occurs when you use
an assert, and the asserted expression is or could
be false.
Note
Polyspace® does not flag assert(0) as
an assertion defect because these statements are commonly used to
disable certain sections of code.
Typically you use assert statements for functional testing in
debug mode. An assertion failure found using static analysis indicates that the
corresponding functional test would fail at run time.
The fix depends on the root cause of the defect. For instance, the root cause can be unconstrained input from an external source that eventually led to the assertion failure.
Often the result details show a sequence of events that led to the defect. You can implement the fix on any event in the sequence. If the result details do not show the event history, you can trace back using right-click options in the source code and see previous related events. See also Interpret Bug Finder Results in Polyspace Desktop User Interface.
See examples of fixes below.
If you do not want to fix the issue, add comments to your result or code to avoid another review. See Address Polyspace Results Through Bug Fixes or Justifications.
| Group: Programming |
| Language: C | C++ |
| Default: On |
Command-Line Syntax: ASSERT |
| Impact: High |