MISRA Discussion Forums
6.2 With Respect to Arrays and Pointers? - 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.6 Types (https://forum.misra.org.uk/forumdisplay.php?fid=33)
+---- Thread: 6.2 With Respect to Arrays and Pointers? (/showthread.php?tid=762)



6.2 With Respect to Arrays and Pointers? - gs - 29-07-2010

Is the following code permitted or prohibited by rule 6.2?
Code:
signed char a[10] = {"123456789"};
signed char *b = "123456789";



Re: 6.2 With Respect to Arrays and Pointers? - misra-c - 06-09-2010

Neither of the examples given is permitted by Rule 6.2..

Here are some more examples:

Code:
signed char a[10] = "123456789";   /* Non-compliant Rule 6.2 */
char a[10] = "123456789";          /* Compliant Rule 6.2 */

char x[4] = {1, 2, 3, 4};          /* Non-compliant Rules 6.2 and 6.3 */