Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rule 19.1 Example
#1
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?
<t></t>
#2
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 */
Posted by and on behalf of the MISRA C Working Group
#3
I was looking at this example and it seems to me that the code

Code:
*p = *q;

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?
#4
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.
Posted by and on behalf of the MISRA C Working Group


Forum Jump:


Users browsing this thread: 4 Guest(s)