6.2 With Respect to Arrays and Pointers?

6.6 Types

Moderators: misra-c, david ward

Post Reply
gs
Posts: 87
Joined: Thu Nov 18, 2004 1:39 am

6.2 With Respect to Arrays and Pointers?

Post by gs » Thu Jul 29, 2010 4:23 pm

Is the following code permitted or prohibited by rule 6.2?

Code: Select all

signed char a[10] = {"123456789"};
signed char *b = "123456789";

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

Re: 6.2 With Respect to Arrays and Pointers?

Post by misra-c » Mon Sep 06, 2010 10:34 am

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

Here are some more examples:

Code: Select all

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 */
---
Posted by and on behalf of
the MISRA C Working Group

Post Reply

Return to “6.6 Types”