Skip to main content

IAR Embedded Workbench for RISC-V 3.40

MISRAC2012-Rule-12.6

In this section:
Synopsis

(Required) Structure and union members of atomic objects shall not be directly accessed

Enabled by default

Yes

Severity/Certainty

High/High

highhigh.png
Full description

Member of atomic object directly accessed.

Coding standards
MISRA C:2012 Rule-12.6

(Required) Structure and union members of atomic objects shall not be directly accessed

Code examples

The following code example fails the check and will give a warning:

typedef struct s { 
  int a;
  int b;
} s_t;

void example(void) { 
  _Atomic s_t astr;
  astr.b = 43; /* Non-compliant */
}

The following code example passes the check and will not give a warning about this issue:

typedef struct s { 
  int a;
  int b;
} s_t;

void example(void) { 
  _Atomic s_t astr;
  s_t lstr = { 7, 42 };
  astr = lstr; /* Compliant */
}