Rule 19.1 Example

Moderators: misra-c, david ward

Post Reply
minoru.kanome
Posts: 1
Joined: Fri Jan 17, 2014 7:18 am
Company: Spansion Innovates Limitted

Rule 19.1 Example

Post by minoru.kanome » Wed Jan 22, 2014 7:33 am

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?

misra-c
Posts: 569
Joined: Thu Jan 05, 2006 1:11 pm

Re: Rule 19.1 Example

Post by misra-c » Mon Feb 03, 2014 8:29 am

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: Select all

  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

Post Reply

Return to “8.19 Overlapping storage”