Hello,
I don't think what I am trying to do is wrong. It compiles in IAR without warning (although I am unable to verify MISRA checking in IAR). I get errors as shown in CCS.
#include "stdint.h"
volatile uint32_t Vol_Array[] = {0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU, 0xFFFFFFFFU};
const uint32_t Const_Array[] = {0x12345678U, 0x87654321U, 0x17171717U, 0x26262626U, 0xa6a6a6a6U};
/* Create a pointer to an array of 5 volatile, constant long integers. */
volatile const uint32_t (*Aray_ptr)[5];
int main(void)
{
/* Without applying a cast to the array address: */
/* #515 a value of type "volatile uint32_t (*)[5]" cannot be assigned to an entity of type "const volatile uint32_t (*)[5]" */
Aray_ptr = &Vol_Array;
/* #515 a value of type "const uint32_t (*)[5]" cannot be assigned to an entity of type "const volatile uint32_t (*)[5]" */
Aray_ptr = &Const_Array;
/* With a cast applied to the array address: */
/* #1402-D (MISRA-C:2004 11.5/R) A cast shall not be performed that removes any const or volatile qualification from the type addressed by a pointer */
Aray_ptr = (const volatile uint32_t (*)[5]) (&Vol_Array);
/* #1402-D (MISRA-C:2004 11.5/R) A cast shall not be performed that removes any const or volatile qualification from the type addressed by a pointer */
Aray_ptr = (const volatile uint32_t (*)[5]) (&Const_Array);
return 0;
}