build: Enforce use of C99 flexible arrays and enable bounds checking

This nudges us towards requiring more compile time array bounds checking
where it’s supported by the compiler.

See https://people.kernel.org/kees/bounded-flexible-arrays-in-c

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
This commit is contained in:
Philip Withnall 2024-02-29 13:47:57 +00:00
parent 1f9bcba295
commit 71aeb3de5a

View File

@ -570,6 +570,10 @@ if cc.get_id() == 'gcc' or cc.get_id() == 'clang'
]
warning_c_args = warning_common_args + [
# Ensure that any use of flexible arrays is C99-compatible
# See https://people.kernel.org/kees/bounded-flexible-arrays-in-c
'-fstrict-flex-arrays',
'-Werror=array-bounds',
'-Wstrict-prototypes',
# Due to pervasive use of things like GPOINTER_TO_UINT(), we do not support
# building with -Wbad-function-cast.