-
Notifications
You must be signed in to change notification settings - Fork 2k
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
cpu/cc26xx_cc13xx: Fix bogus array-bound warning [backport 2023.04] #19509
cpu/cc26xx_cc13xx: Fix bogus array-bound warning [backport 2023.04] #19509
Conversation
GCC 12 create a bogus array out of bounds warning as it assumes that because there is special handling for `uart == 0` and `uart == 1`, `uart` can indeed be `1`. There is an `assert(uart < UART_NUMOF)` above that would blow up prior to any out of bounds access. In any case, optimizing out the special handling of `uart == 1` for when `UART_NUMOF == 1` likely improves the generated code and fixes the warning. /home/maribu/Repos/software/RIOT/cc2650/cpu/cc26xx_cc13xx/periph/uart.c:88:8: error: array subscript 1 is above array bounds of 'uart_isr_ctx_t[1]' [-Werror=array-bounds] 88 | ctx[uart].rx_cb = rx_cb; | ~~~^~~~~~ /home/maribu/Repos/software/RIOT/cc2650/cpu/cc26xx_cc13xx/periph/uart.c:52:23: note: while referencing 'ctx' 52 | static uart_isr_ctx_t ctx[UART_NUMOF]; | ^~~ /home/maribu/Repos/software/RIOT/cc2650/cpu/cc26xx_cc13xx/periph/uart.c:89:8: error: array subscript 1 is above array bounds of 'uart_isr_ctx_t[1]' [-Werror=array-bounds] 89 | ctx[uart].arg = arg; | ~~~^~~~~~ /home/maribu/Repos/software/RIOT/cc2650/cpu/cc26xx_cc13xx/periph/uart.c:52:23: note: while referencing 'ctx' 52 | static uart_isr_ctx_t ctx[UART_NUMOF]; | ^~~ (cherry picked from commit d6499fa)
OK, we will add this in but not create a new RC, if there is something else that comes up that is worth doing a point release it will be added. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK
bors merge |
bors cancel |
Canceled. |
This should be merged into the release branch after the release is finished. |
Now that the release is done, bors merge |
bors merge |
Build succeeded: |
Backport of #19504
Contribution description
GCC 12 create a bogus array out of bounds warning as it assumes that because there is special handling for
uart == 0
anduart == 1
,uart
can indeed be1
. There is anassert(uart < UART_NUMOF)
above that would blow up prior to any out of bounds access.In any case, optimizing out the special handling of
uart == 1
for whenUART_NUMOF == 1
likely improves the generated code and fixes the warning.Testing procedure
The actual change is a pretty obvious one-liner, so that code review and a green CI should be sufficient. If not, running any UART example app without regression should do.
Issues/PRs references
None