Has the error in the function LL_ADC_SetChannelSingleDiff() been fixed?
The function LL_ADC_SetChannelSingleDiff() in stm32l4xx_ll_adc.h relies on
shifting a 32 bit value 32 postions in order to clear a bit field.
Shifting a word with >= the word size is undefined in the C standard and this
generates erronous code when compiled with for example gcc 7.2.1 and optimzation -O1.
This error is manifested in the function HAL_ADC_ConfigChannel() when initiating an ADC channel as single-ended it will be initiated as differential.
Complete compiler command used when problem occurred:
arm-none-eabi-gcc-7.2.1.exe -DARM_MATH_CM4 -DSTM32L432xx=1 -D__FPU_PRESENT=1 -D__FPU_USED=1U -mfloat-abi=hard -mcpu=cortex-m4 -mthumb -mlittle-endian -mfpu=fpv4-sp-d16 -ffunction-sections -std=c99 -fdata-sections -fverbose-asm -Wall -Wstrict-prototypes -Wdouble-promotion -g -gdwarf-2 -O1 -save-temps -Werror xxxx\stm32l4xx_hal_adc.c
Compiling with optimization -Og generates correct code.
Have tried both STM32Cube_FW_L4_V1.10.0 and STM32Cube_FW_L4_V1.14.0, which have slightly different implementations of "LL_ADC_SetChannelSingleDiff()", though both have undefined behavior according to the C standard, see for example:
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf
In section 6.5.7 Bitwise shift operators:
If the value of the right operand is negative or is greater than or equal to the width of the promoted left operand, the behavior is undefined.
