Partial initialization of InitTypeDef structures
Hi,
Partial initialization of the Init structures in the CubeMX generated code is quite common:
static void MX_GPIO_Init(void)
{
GPIO_InitTypeDef GPIO_InitStruct;
...
/*Configure GPIO pin : MY_PIN_13_Pin */
GPIO_InitStruct.Pin = MY_PIN_13_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
HAL_GPIO_Init(MY_PIN_13_GPIO_Port, &GPIO_InitStruct);
According to the language standard, the initial state of local variables is undefined, so the uninitialized fields of an Init structure must contain garbage, which simply cannot work.
Does it mean that local variables get zero-initialized after all? In case of our toolchain, that is.