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 atomic variable is accessed, but it has not been initialized. There are two cases:
For the sake of this check, a variable is considered to be atomic if it is declared with the _Atomic type specifier or has any atomic type defined in <stdatomic.h>.
Note: if an atomic variable is used without being initialized, CodeSonar will issue an Uninitialized Variable warning.
| Class Name | Inappropriate C Atomic Initialization | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Significance | reliability | ||||||||||||||||||||||||||||||
| Mnemonic | CONCURRENCY.C_ATOMIC.INIT | ||||||||||||||||||||||||||||||
| Categories |
|
||||||||||||||||||||||||||||||
| Availability | Available for C and C++. |
||||||||||||||||||||||||||||||
| Enabling | Checks for this warning class are enabled by
default. To disable them, add the following WARNING_FILTER rule to the
project configuration file.
WARNING_FILTER += discard class="Inappropriate C Atomic Initialization" |
#include <stdint.h>
#include <stdatomic.h>
int32_t concurrency_c_atomic_init( void ){
_Atomic int32_t good1 = 111; /* ok: direct initialization */
_Atomic int32_t good2;
int32_t _Atomic * goodp;
_Atomic int32_t bad1;
_Atomic int32_t bad2;
_Atomic int32_t bad3;
int32_t _Atomic * badp;
atomic_init(&good2, 222); /* ok: initialization with atomic_init() */
good1 = 555; /* ok: good1 previously initialized */
goodp = &good2; /* ok: good2 previously initialized */
bad1 = 333; /* 'Inappropriate C Atomic Initialization' warning issued here
* - not direct initialization and not using atomic_init()
*/
badp = &bad2; /* 'Inappropriate C Atomic Initialization' warning issued here
* - taking address of uninitialized atomic variable
*/
*badp = 444; /* 'Inappropriate C Atomic Initialization' warning issued here
* - writing through pointer into uninitialized atomic variable
*/
return bad3; /* 'Uninitialized Variable' warning issued here
* - use of ininitialized atomic variable
*/
}
The following configuration file parameters affect checks for this warning class.
To report problems with this documentation, please visit https://support.codesecure.com/.