Compile failure with gcc 12: -Werror=array-bounds in src/cjhtextregion.c
While updating the gnome-text-editor package for Fedora, I came across this build failure:
In file included from ../src/cjhtextregion.c:24:
../src/cjhtextregion.c: In function ‘cjh_text_region_leaf_split.constprop.0’:
../src/cjhtextregionbtree.h:296:26: error: array subscript 255 is above array bounds of ‘struct CjhTextRegionRun[26]’ [-Werror=array-bounds]
296 | _ele = (FIELD)->items[_pos]; \
| ~~~~~~~~~~~~~~^~~~~~
../src/cjhtextregionbtree.h:221:10: note: while referencing ‘items’
221 | TYPE items[N_ITEMS]; \
| ^~~~~
../src/cjhtextregionbtree.h:296:26: error: array subscript 255 is above array bounds of ‘struct CjhTextRegionRun[26]’ [-Werror=array-bounds]
296 | _ele = (FIELD)->items[_pos]; \
| ~~~~~~~~~~~~~~^~~~~~
../src/cjhtextregionbtree.h:221:10: note: while referencing ‘items’
221 | TYPE items[N_ITEMS]; \
| ^~~~~
../src/cjhtextregion.c: In function ‘cjh_text_region_branch_split.constprop.0’:
../src/cjhtextregionbtree.h:296:26: error: array subscript 255 is above array bounds of ‘struct CjhTextRegionChild[26]’ [-Werror=array-bounds]
296 | _ele = (FIELD)->items[_pos]; \
| ~~~~~~~~~~~~~~^~~~~~
../src/cjhtextregionbtree.h:221:10: note: while referencing ‘items’
221 | TYPE items[N_ITEMS]; \
| ^~~~~
../src/cjhtextregionbtree.h:296:26: error: array subscript 255 is above array bounds of ‘struct CjhTextRegionChild[26]’ [-Werror=array-bounds]
296 | _ele = (FIELD)->items[_pos]; \
| ~~~~~~~~~~~~~~^~~~~~
../src/cjhtextregionbtree.h:221:10: note: while referencing ‘items’
221 | TYPE items[N_ITEMS]; \
| ^~~~~
../src/cjhtextregion.c: In function ‘cjh_text_region_root_split.constprop.0’:
../src/cjhtextregionbtree.h:296:26: error: array subscript 255 is above array bounds of ‘struct CjhTextRegionChild[26]’ [-Werror=array-bounds]
296 | _ele = (FIELD)->items[_pos]; \
| ~~~~~~~~~~~~~~^~~~~~
../src/cjhtextregionbtree.h:221:10: note: while referencing ‘items’
221 | TYPE items[N_ITEMS]; \
| ^~~~~
../src/cjhtextregionbtree.h:296:26: error: array subscript 255 is above array bounds of ‘struct CjhTextRegionChild[26]’ [-Werror=array-bounds]
296 | _ele = (FIELD)->items[_pos]; \
| ~~~~~~~~~~~~~~^~~~~~
../src/cjhtextregionbtree.h:221:10: note: while referencing ‘items’
221 | TYPE items[N_ITEMS]; \
| ^~~~~
../src/cjhtextregionbtree.h:296:26: error: array subscript 255 is above array bounds of ‘struct CjhTextRegionChild[26]’ [-Werror=array-bounds]
296 | _ele = (FIELD)->items[_pos]; \
| ~~~~~~~~~~~~~~^~~~~~
../src/cjhtextregionbtree.h:221:10: note: while referencing ‘items’
221 | TYPE items[N_ITEMS]; \
| ^~~~~
../src/cjhtextregionbtree.h:296:26: error: array subscript 255 is above array bounds of ‘struct CjhTextRegionChild[26]’ [-Werror=array-bounds]
296 | _ele = (FIELD)->items[_pos]; \
| ~~~~~~~~~~~~~~^~~~~~
../src/cjhtextregionbtree.h:221:10: note: while referencing ‘items’
221 | TYPE items[N_ITEMS]; \
| ^~~~~
cc1: some warnings being treated as errors
I do not know why gcc 12 is tripping up on this now, as the static asserts seem to cover the > 254 case.