Rule 17.5 and arrays of size 1 - 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.17 Functions (https://forum.misra.org.uk/forumdisplay.php?fid=172) +---- Thread: Rule 17.5 and arrays of size 1 (/showthread.php?tid=1423) |
Rule 17.5 and arrays of size 1 - gdavis - 15-05-2018 Hello, Please consider the following case: Code: #include Could you confirm if the intent that this should be a violation of the rule since we are passing a non-array as an argument where an array is expected? I ask only because there is related wording in the C90/99 standard under additive operators that states: Quote:For the purposes of these operators, a pointer to a nonarray object behaves the same as a Thank you for your help. Best Regards, -Greg Re: Rule 17.5 and arrays of size 1 - misra-c - 08-06-2018 Your example is not a violation of rule 17.5. The Amplification states that the argument Quote:... should point into an object that has at least as many elements as the array.As you quoted, the C standard states that "&glob" should behave as if it were a pointer to the first element of an array of length one. The expected size in "f" is one, and so the example is compliant. |