Possible shift by negative amount in modules arm_lms_norm_q31 and am_lms_norm_q15
localuser2 opened this issue · 1 comments
localuser2 commented
Compiling current CMSIS for Host platfom (AMD64) while gcc's static code analysis feature is active results in serious looking errors.
GCC version:
$ gcc --version
gcc (Ubuntu 11.2.0-19ubuntu1) 11.2.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
GCC arguments:
/usr/bin/x86_64-linux-gnu-gcc -DARM_MATH_LOOPUNROLL -D__GNUC_PYTHON__ -I/home/klose/projects/MARS2/mars/cxx/libraries/mars-processing/src/CMSIS/CMSIS/DSP/PrivateInclude -I/home/klose/projects/MARS2/mars/cxx/libraries/mars-processing/src/CMSIS/CMSIS/DSP/Include -g -Og -Wall -Wextra -Werror -I /home/klose/projects/MARS2/mars/dev_policies/cxx/cmake/../include/ -fanalyzer -MD -MT mars-processing-bin/src/cmsis_dsp_bin/FilteringFunctions/CMakeFiles/CMSISDSPFiltering.dir/arm_lms_norm_q15.c.obj -MF CMakeFiles/CMSISDSPFiltering.dir/arm_lms_norm_q15.c.obj.d -o CMakeFiles/CMSISDSPFiltering.dir/arm_lms_norm_q15.c.obj -c /home/klose/projects/MARS2/mars/cxx/libraries/mars-processing/src/CMSIS/CMSIS/DSP/Source/FilteringFunctions/arm_lms_norm_q15.c
GCC code analyzer warnings (with the configuration shown above this are errors due to -Werror
):
/home/klose/projects/MARS2/mars/cxx/libraries/mars-processing/src/CMSIS/CMSIS/DSP/Source/FilteringFunctions/arm_lms_norm_q31.c:189:9: error: shift by negative count (‘-1’) [-Werror=analyzer-shift-count-negative]
189 | w = clip_q63_to_q31(((q63_t) errorXmu * oneByEnergy) >> (31 - postShift));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
‘arm_lms_norm_q31’: events 1-2
|
| 102 | while (blkCnt > 0U)
| | ~~~~~~~^~~~
| | |
| | (1) following ‘true’ branch (when ‘blkCnt != 0’)...
|......
| 105 | *pStateCurnt++ = *pSrc;
| | ~
| | |
| | (2) ...to here
|
‘arm_lms_norm_q31’: event 3
|
|/home/klose/projects/MARS2/mars/cxx/libraries/mars-processing/src/CMSIS/CMSIS/DSP/Include/dsp/none.h:65:10:
| 65 | if (data == 0U) { return 32U; }
| | ^
| | |
| | (3) following ‘true’ branch...
|
‘arm_lms_norm_q31’: events 4-6
|
|/home/klose/projects/MARS2/mars/cxx/libraries/mars-processing/src/CMSIS/CMSIS/DSP/Include/dsp/utils.h:63:31:
| 63 | signBits = ((uint32_t) (__CLZ( in) - 1));
| | ^~~~~~~~~~
| | |
| | (4) ...to here
|......
| 82 | for (i = 0U; i < 2U; i++)
| | ~~~~~~
| | |
| | (5) following ‘true’ branch (when ‘i <= 1’)...
| 83 | {
| 84 | tempVal = (uint32_t) (((q63_t) in * out) >> 31);
| | ~~~~~~~
| | |
| | (6) ...to here
|
‘arm_lms_norm_q31’: event 7
|
|/home/klose/projects/MARS2/mars/cxx/libraries/mars-processing/src/CMSIS/CMSIS/DSP/Source/FilteringFunctions/arm_lms_norm_q31.c:189:9:
| 189 | w = clip_q63_to_q31(((q63_t) errorXmu * oneByEnergy) >> (31 - postShift));
| | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| | |
| | (7) shift by negative amount here (‘-1’)
|
cc1: all warnings being treated as errors
make[2]: *** [mars-processing-bin/src/cmsis_dsp_bin/FilteringFunctions/CMakeFiles/CMSISDSPFiltering.dir/build.make:1420: mars-processing-bin/src/cmsis_dsp_bin/FilteringFunctions/CMakeFiles/CMSISDSPFiltering.dir/arm_lms_norm_q31.c.obj] Fehler 1
make[2]: *** Auf noch nicht beendete Prozesse wird gewartet …
/home/klose/projects/MARS2/mars/cxx/libraries/mars-processing/src/CMSIS/CMSIS/DSP/Include/dsp/utils.h: In function ‘arm_lms_norm_q15’:
/home/klose/projects/MARS2/mars/cxx/libraries/mars-processing/src/CMSIS/CMSIS/DSP/Source/FilteringFunctions/arm_lms_norm_q15.c:185:45: error: shift by negative count (‘-1’) [-Werror=analyzer-shift-count-negative]
185 | acc = (((q31_t) errorXmu * oneByEnergy) >> (15 - postShift));
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
‘arm_lms_norm_q15’: events 1-2
|
| 102 | while (blkCnt > 0U)
| | ~~~~~~~^~~~
| | |
| | (1) following ‘true’ branch (when ‘blkCnt != 0’)...
|......
| 105 | *pStateCurnt++ = *pSrc;
| | ~
| | |
| | (2) ...to here
|
‘arm_lms_norm_q15’: event 3
|
|/home/klose/projects/MARS2/mars/cxx/libraries/mars-processing/src/CMSIS/CMSIS/DSP/Include/dsp/none.h:65:10:
| 65 | if (data == 0U) { return 32U; }
| | ^
| | |
| | (3) following ‘true’ branch...
|
‘arm_lms_norm_q15’: events 4-6
|
|/home/klose/projects/MARS2/mars/cxx/libraries/mars-processing/src/CMSIS/CMSIS/DSP/Include/dsp/utils.h:114:30:
| 114 | signBits = ((uint32_t)(__CLZ( in) - 17));
| | ^~~~~~~~~~
| | |
| | (4) ...to here
|......
| 133 | for (i = 0U; i < 2U; i++)
| | ~~~~~~
| | |
| | (5) following ‘true’ branch (when ‘i <= 1’)...
| 134 | {
| 135 | tempVal = (uint32_t) (((q31_t) in * out) >> 15);
| | ~~~~~~~
| | |
| | (6) ...to here
|
‘arm_lms_norm_q15’: event 7
|
|/home/klose/projects/MARS2/mars/cxx/libraries/mars-processing/src/CMSIS/CMSIS/DSP/Source/FilteringFunctions/arm_lms_norm_q15.c:185:45:
| 185 | acc = (((q31_t) errorXmu * oneByEnergy) >> (15 - postShift));
| | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
| | |
| | (7) shift by negative amount here (‘-1’)
|
JonatanAntoni commented
Hi @localuser2,
Please take note that CMSIS-DSP has moved into its own repository at https://github.com/ARM-software/CMSIS-DSP. Please consider raising your issue over there.
Thanks,
Jonatan