
...
In this noncompliant code example, a volatile object is accessed through a non-volatile-qualified reference, resulting in undefined behavior 62:
Code Block | ||||
---|---|---|---|---|
| ||||
#include <stdio.h> void func(void) { static volatile int **ipp; static int *ip; static volatile int i = 0; printf("i = %d.\n", i); ipp = &ip; /* May produce a warning diagnostic */ ipp = (int**) &ip; /* Constraint violation; may produce a warning diagnostic */ *ipp = &i; /* Valid */ if (*ip != 0) { /* Valid */ /* ... */ } } |
...
Accessing an object with a volatile-qualified type through a reference with a non-volatile-qualified type is undefined behavior 62.
Rule | Severity | Likelihood | Remediation Cost | Priority | Level |
---|---|---|---|---|---|
EXP32-C | Low | Likely | Medium | P6 | L2 |
...