fix 'array subscript 0 is outside array bounds' for newer gcc versions #273
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.