MISRA Discussion Forums
Rule 19.1 Example - Printable Version

+- MISRA Discussion Forums (https://forum.misra.org.uk)
+-- Forum: MISRA C (https://forum.misra.org.uk/forumdisplay.php?fid=4)
+--- Forum: MISRA C:2012 and MISRA C:2023 guidelines (https://forum.misra.org.uk/forumdisplay.php?fid=21)
+---- Forum: 8.19 Overlapping storage (https://forum.misra.org.uk/forumdisplay.php?fid=174)
+---- Thread: Rule 19.1 Example (/showthread.php?tid=1022)



Rule 19.1 Example - minoru.kanome - 22-01-2014

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?


Re: Rule 19.1 Example - misra-c - 03-02-2014

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 */



RE: Rule 19.1 Example - [email protected] - 11-10-2023

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?


RE: Rule 19.1 Example - misra-c - 13-03-2024

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.