MISRA Discussion Forums
MISRA2004 Rule 17.4 How to solve the Rule violation - 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: MISRA2004 Rule 17.4 How to solve the Rule violation (/showthread.php?tid=1472)



MISRA2004 Rule 17.4 How to solve the Rule violation - Tejas Kore - 19-02-2019

I have an issue regarding the rule violation in which I'm using a 2D array inside a structure and apparently The Rule 17.4 says it isn't compliant. Is Declaring arryas inside a structure/union not compliant and why is it so? What exactly is the alternative for it?
Help would be appreciated ASAP. Following is the example code. Thanks in advance.

Code:
#include
void func1(unsigned char abc);

typedef struct teststructure
{
    float buf[5][3];
}teststruct;

int main()
{
    unsigned char abc;

    func1(abc);

}

void func1(unsigned char abc)
{
    teststruct TEST;

    float fData = 54.0;
    TEST.buf[2][1] = fData;
}



Re: MISRA2004 Rule 17.4 How to solve the Rule violation - dg1980 - 20-02-2019

This is most likely a false positive from the static analysis tool you are using.
Rule 17.4 bans pointer arithmetic but in your sample you use array indexing only, so it is compliant.
I suggest contacting your tool vendors support.


Re: MISRA2004 Rule 17.4 How to solve the Rule violation - misra-c - 07-03-2019

There is no violation of rule 17.4.


Re: MISRA2004 Rule 17.4 How to solve the Rule violation - david ward - 30-04-2019

Question moved here to the correct location