...
Other uses of static assertion are shown in STR07-A. Use TR 24731 for remediation of existing string manipulation code and FIO35-C. Use feof() and ferror() to detect end-of-file and file errors when sizeof(int) == sizeof(char).
Automated Detection
Compass/ROSE could detect violations of this rule merely by looking for calls to assert()
, and if it is able to evaluate the assertion (due to all values being known at compile time), then the code should use static-assert
instead.
This assumes ROSE can recognize macro invocation.
Risk Assessment
Static assertion is a valuable diagnostic tool for finding and eliminating software defects that may result in vulnerabilities at compile time. The absence of static assertions, however, does not mean that code is incorrect.
...