JavaScript is not currently enabled, but is required for full CodeSonar manual search and browse functionality.
If you are viewing this file in your hub's Web GUI, enable JavaScript in your browser: you will also need it for GUI functionality.
If you opened this file directly from disk, your browser may be directly suppressing JavaScript functionality: certain browsers perform this suppression on local files (but not files delivered by web servers) for security reasons.
| CodeSonar® 9.2p0 | CONFIDENTIAL | CodeSecure Inc |
An initializer list contains one or more side effects.
For the sake of this check:
| Class Name | Side Effects in Initializer List | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Significance | style | |||||||||||||||
| Mnemonic | LANG.STRUCT.SE.INIT | |||||||||||||||
| Categories |
|
|||||||||||||||
| Availability | Available for C and C++. |
|||||||||||||||
| Enabling | Checks for this warning class are disabled by default,
and require the unnormalized
C ASTs for the project. To enable them, add the following
WARNING_FILTER rule and RETAIN_UNNORMALIZED_C_AST specification to the project configuration file.
RETAIN_UNNORMALIZED_C_AST = Yes WARNING_FILTER += allow class="Side Effects in Initializer List" |
#include <string.h>
int f(int i);
int g(int i) __attribute__((const));
int h(int i) __attribute__((pure));
int SE_INIT(int x, int y, volatile int *z, char *s){
int A[2] = {x+y, x-y}; /* no side effects */
if (!A[1]){return 1;}
int B[2] = {x++, y++}; /* 'Side Effects in Initializer List' warning issued here */
if (!B[1]){return 1;}
int C[2] = {y, *z}; /* 'Side Effects in Initializer List' warning issued here */
if (!C[1]){return 1;}
int D[2] = {1, z[1]}; /* 'Side Effects in Initializer List' warning issued here */
if (!D[1]){return 1; }
int E[2] = {1, f(x)}; /* 'Side Effects in Initializer List' warning issued here */
if (!E[1]){return 1;}
int F[2] = {1, g(x)}; /* g() declared with __attribute__((const)) */
if (!F[1]){return 1;}
int G[2] = {1, h(x)}; /* g() declared with __attribute__((pure)) */
if (!G[1]){return 1;}
int H[2] = {1, strlen(s)}; /* strlen() matches a factory setting for SIDE_EFFECT_FREE_FUNCTIONS */
return H[1];
/* ... */
}
The following configuration file parameters affect checks for this warning class.
To report problems with this documentation, please visit https://support.codesecure.com/.