From b9b572335e477037226f603a3265b0b3091ed0d7 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Fri, 1 Aug 2025 15:08:03 -0500 Subject: [PATCH] bsps/powerpc/include/mpc8xx.h: Disable zero length array A padding array ends up with a size of 0 which is illegal in newer versions of C -- at least C17 and later. --- bsps/powerpc/include/mpc8xx.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/bsps/powerpc/include/mpc8xx.h b/bsps/powerpc/include/mpc8xx.h index 3e9be35d5d..2bf8d00c90 100644 --- a/bsps/powerpc/include/mpc8xx.h +++ b/bsps/powerpc/include/mpc8xx.h @@ -1478,7 +1478,13 @@ typedef struct m8xx_ { m8xxSPIparms_t spip; uint8_t _rsv5[0xDB0-0xD80-sizeof(m8xxSPIparms_t)]; m8xxTimerParms_t tmp; + /* + * This calculation results in a zero length array which is interpreted + * differently starting in C17. No padding is needed and there is a + * static assert below to double check the assumption. + * uint8_t _rsv6[0xDC0-0xDB0-sizeof(m8xxTimerParms_t)]; + */ m8xxIDMAparms_t idma2p; uint8_t _rsv7[0xE00-0xDC0-sizeof(m8xxIDMAparms_t)]; @@ -1499,6 +1505,15 @@ typedef struct m8xx_ { extern volatile m8xx_t m8xx; +/* + * The sizeof(m8xxTimerParms_t) is 16 and the _rsv6 element is not needed and + * is commented out. If the assumption breaks, it needs to be added back. + */ +RTEMS_STATIC_ASSERT( + 0xDC0-0xDB0-sizeof(m8xxTimerParms_t) == 0, + _rsv6 size computation +); + #ifdef __cplusplus } #endif