unititialized value reported by compiler Topic is solved

Report here problems in any of ChibiOS components. This forum is NOT for support.
User avatar
alex31
Posts: 338
Joined: Fri May 25, 2012 10:23 am
Location: toulouse, france
Has thanked: 34 times
Been thanked: 50 times
Contact:

unititialized value reported by compiler  Topic is solved

Postby alex31 » Mon Apr 12, 2021 1:41 pm

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

User avatar
Giovanni
Site Admin
Posts: 13585
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 876 times
Been thanked: 750 times
Contact:

Re: unititialized value reported by compiler

Postby Giovanni » Sat Apr 24, 2021 9:07 am

Hi,

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

Giovanni

User avatar
alex31
Posts: 338
Joined: Fri May 25, 2012 10:23 am
Location: toulouse, france
Has thanked: 34 times
Been thanked: 50 times
Contact:

Re: unititialized value reported by compiler

Postby alex31 » Sun Apr 25, 2021 3:12 pm

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

User avatar
Giovanni
Site Admin
Posts: 13585
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 876 times
Been thanked: 750 times
Contact:

Re: unititialized value reported by compiler

Postby Giovanni » Sat May 08, 2021 9:28 am

Hi,

Fixed as bug #1158.

Giovanni


Return to “Bug Reports”

Who is online

Users browsing this forum: Bing [Bot] and 3 guests