Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GCC compiler warning in arm_divide_q15() #159

Closed
felixvanoost opened this issue Feb 29, 2024 · 1 comment
Closed

GCC compiler warning in arm_divide_q15() #159

felixvanoost opened this issue Feb 29, 2024 · 1 comment
Labels
DONE Issue done but not yet closed warning Compilation warning to remove

Comments

@felixvanoost
Copy link
Contributor

When compiling CMSIS-DSP using GCC 10.3, the compiler produces the following warning in arm_divide_q15():

[build] Source/FastMathFunctions/arm_divide_q15.c: In function 'arm_divide_q15':
[build] Source/FastMathFunctions/arm_divide_q15.c:77:21: error: overflow in conversion from 'int' to 'q15_t' {aka 'short int'} changes value from '32768' to '-32768' [-Werror=overflow]
[build]    77 |         *quotient = 0x8000;
[build]       |                     ^~~~~~

0x8000 represents the positive integer 32768, but what was actually intended by the writer is the two's complement representation of -32768. Replacing 0x8000 with -32768 resolves the compiler warning and avoids further ambiguity.

@christophe0606
Copy link
Contributor

@felixvanoost Thanks. I'll pass a few regression tests and I'll merge the PR.

@christophe0606 christophe0606 added the warning Compilation warning to remove label Mar 4, 2024
christophe0606 added a commit that referenced this issue Mar 4, 2024
@christophe0606 christophe0606 added the DONE Issue done but not yet closed label Mar 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DONE Issue done but not yet closed warning Compilation warning to remove
Projects
None yet
Development

No branches or pull requests

2 participants