MISRA Discussion Forums
Rule 17.4 - 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: 2004 rules (https://forum.misra.org.uk/forumdisplay.php?fid=17)
+---- Forum: 6.17 Pointers and Arrays (https://forum.misra.org.uk/forumdisplay.php?fid=44)
+---- Thread: Rule 17.4 (/showthread.php?tid=727)



Rule 17.4 - mshearer123 - 31-03-2010

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

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

mID tester;
Code:
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


Re: Rule 17.4 - Lundin - 07-04-2010

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.


Re: Rule 17.4 - misra-c - 13-05-2010

This code does not violate Rule 17.4.