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

fix 'array subscript 0 is outside array bounds' for newer gcc versions #273

Merged
merged 1 commit into from Sep 8, 2022

Conversation

gibbz00
Copy link
Contributor

@gibbz00 gibbz00 commented Aug 29, 2022

I'm got the following error when building:

lib/sdk11/components/libraries/bootloader_dfu/bootloader_settings.c: In function 'bootloader_mbr_addrs_populate': lib/sdk11/components/libraries/bootloader_dfu/bootloader_settings.c:45:7: error: array subscript 0 is outside array bounds of 'const uint 32_t[0]' {aka 'const long unsigned int[]'} [-Werror=array-bounds] 45 | if (*(const uint32_t *)MBR_BOOTLOADER_ADDR == 0xFFFFFFFF) compilation terminated due to -Wfatal-errors. cc1: all warnings being treated as errors make: *** [Makefile:393: _build/build-feather_nrf52840_express/bootloader_settings.o] Error 1

Looked around and found this issue over at QMK: qmk/qmk_firmware#17064
The main bug referenced can be found here: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105523

In essence: gcc versions of 12 and above have a regression bug that can be solved by adding the compile flag --param=min-pagesize=0. The surrounding conditional in the commit checks that the flag is supported. (Small adaptations to QMKs fix really; qmk/qmk_firmware@2160810)

Anyway, building works well for me with this minor change.

@ladyada ladyada requested a review from hathach August 29, 2022 17:15
Copy link
Member

@hathach hathach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you for the fix. Indeed I have encountered some issue with gcc throwing incorrect warning lately.

@hathach hathach merged commit de32e8c into adafruit:master Sep 8, 2022
@gibbz00 gibbz00 deleted the build-fix branch September 9, 2022 14:59
@zvrh
Copy link

zvrh commented Jan 28, 2024

This problem appeared again on gcc13, and only gcc12 was judged in the code.

# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105523
ifneq ($(findstring 12.,$(shell $(CC) --version 2>/dev/null)),)
CFLAGS += --param=min-pagesize=0
endif

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants