Skip to content

Fix array-bounds build error

Kairui Song requested to merge ryncsn/gtk:gtk-3-24 into gtk-3-24

Hi, this MR is trying to fix a build error on 3.24 branch with GCC 12, the same issue also exists on master branch, but I want to collect some comment, if this fix is OK I can make another MR for master branch as well.

When building with gcc-12.0.1, following error occur:

../gtk/gtkimagedefinition.c:129:24: error: array subscript ‘union GtkImageDefinition[0]’ is partly outside array bounds of ‘unsigned char[16]’ [-Werror=array-bounds]

It seems the array-bounds check in GCC 12 is more aggresive and doesn't play well with GtkImageDefinition.

Refractor the code a bit, alloc and cast the right struct type explicitly to comply with the compiler.

Signed-off-by: Kairui Song kasong@tencent.com

Merge request reports