Rule 17.4

6.17 Pointers and Arrays

Moderators: misra-c, david ward

Post Reply
mshearer123
Posts: 14
Joined: Thu Feb 18, 2010 11:28 am
Company: TME

Rule 17.4

Post by mshearer123 » Wed Mar 31, 2010 8:25 am

Hi,
I am finding a violation (with IBM logiscope) when i use an array within a structure.

so my structure is:

Code: Select all

typedef struct
{
unsigned char a;
unsigned char b;
unsigned char c[10];
unsigned char d;
}mID;
and my main:

mID tester;

Code: Select all

int main(void)
{
tester.a = 0x01;
tester.c[2] = 0x02;
tester.c[3] = 0x06;
tester.c[4] = 0x05;
return 0;
}
for each assignment to .c i am told "pointer arithmetic only with array indexing"

thanks for any advice

matt

Lundin
Posts: 70
Joined: Mon Dec 10, 2007 1:57 pm

Re: Rule 17.4

Post by Lundin » Wed Apr 07, 2010 9:49 am

It would seem that your static analyzer is flawed. The only problem with that code is that you are declaring mID global, which violates rule 8.7.

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

Re: Rule 17.4

Post by misra-c » Thu May 13, 2010 10:51 am

This code does not violate Rule 17.4.
---
Posted by and on behalf of
the MISRA C Working Group

Post Reply

Return to “6.17 Pointers and Arrays”