Page 1 of 1

unititialized value reported by compiler  Topic is solved

Posted: Mon Apr 12, 2021 1:41 pm
by alex31
chibios 20.3, compiler gcc 10.2

Code: Select all

Compiling stm32_bdma.c
../../../ChibiOS_20.3_stable/os/hal/ports/STM32/LLD/ADCv4/hal_adc_lld.c: In function 'adc_lld_start_conversion':
../../../ChibiOS_20.3_stable/os/hal/ports/STM32/LLD/ADCv4/hal_adc_lld.c:694:23: error: 'cfgr' may be used uninitialized in this function [-Werror=maybe-uninitialized]
  694 |     adcp->adcm->CFGR  = cfgr;


In fact the variable is only uninitialized if we pass incorrect ADC driver address, neither &ADC1 nor &ADC3, but the compiler cannot guess that. Simple fix is initializing cfgr with 0 on the declaration line.

Alexandre

Re: unititialized value reported by compiler

Posted: Sat Apr 24, 2021 9:07 am
by Giovanni
Hi,

What compiler settings are you using? I don't see that warning in the ADC demo.

Giovanni

Re: unititialized value reported by compiler

Posted: Sun Apr 25, 2021 3:12 pm
by alex31
Hello,

I use developper.arm.com gcc 10.2 compiler.

The warning is triggered if compiled with -0g and without LTO.

(With LTO, the compiler knows that driver parameter is ADCD1 and cfgr cannot be uninitialized since it passes in the ADCD1 branch)

Alexandre

Re: unititialized value reported by compiler

Posted: Sat May 08, 2021 9:28 am
by Giovanni
Hi,

Fixed as bug #1158.

Giovanni