rule 19.1 example :
a = b; /* Compliant - exception 1 */
a and b are not overlapping object.
Therefore, this code is improper as the example.
Is it right?
Thank you for bringing this to our attention. You are correct to say that the line "a=b" is not a relevant example for this rule and there is no overlap between a and b.
The "*p = *q" is a correct example of exception 1, as would be the following
Code:
union
{
int16_t i;
int32_t j;
int16_t k;
}a = {0};
a.i = a.k; /* Compliant - exception 1 */
I was looking at this example and it seems to me that the code
might be considered as dead code, which is a violation to a required rule (R 2.2).
Is this just a dummy example for this specific rule or this code can be considered as fully compliant to MISRA?
As specified in Section 6.9 examples are illustrative, and may be incomplete for the sake of brevity.
The example "*p = *q" is used to illustrate R.19.1, but may be a violation of other guidelines.
In MISRA C:2023 the example "a = b" has been removed.