mirror of
https://github.com/systemd/systemd-stable.git
synced 2024-12-23 17:34:00 +03:00
meson: enable -Warray-bounds and -fstrict-flex-arrays
-fstrict-flex-arrays means that the compiler doesn't have to assume that any trailing array is a flex array. I.e. unless the array is declared without a specified size, only indices in the declared range are valid. -Warray-bounds turns on the warnings about out-of-bounds array accesses. -Warray-bounds=2 does some more warnings, with higher false positive rate. But it doesn't seem to yield any false positives in our codebase, so enable it. clang supports -Warray-bounds, but not -Warray-bounds=2. gcc supports both. gcc-13 supports -fstrict-flex-arrays. See https://people.kernel.org/kees/bounded-flexible-arrays-in-c for a long discussion of use in the kernel.
This commit is contained in:
parent
f41e4b82a4
commit
fc5688375c
@ -354,6 +354,8 @@ basic_disabled_warnings = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
possible_common_cc_flags = [
|
possible_common_cc_flags = [
|
||||||
|
'-Warray-bounds', # clang
|
||||||
|
'-Warray-bounds=2',
|
||||||
'-Wdate-time',
|
'-Wdate-time',
|
||||||
'-Wendif-labels',
|
'-Wendif-labels',
|
||||||
'-Werror=format=2',
|
'-Werror=format=2',
|
||||||
@ -391,6 +393,8 @@ possible_common_cc_flags = [
|
|||||||
# negative arguments are correctly detected starting with meson 0.46.
|
# negative arguments are correctly detected starting with meson 0.46.
|
||||||
'-Wno-error=#warnings', # clang
|
'-Wno-error=#warnings', # clang
|
||||||
'-Wno-string-plus-int', # clang
|
'-Wno-string-plus-int', # clang
|
||||||
|
|
||||||
|
'-fstrict-flex-arrays',
|
||||||
]
|
]
|
||||||
|
|
||||||
c_args = get_option('c_args')
|
c_args = get_option('c_args')
|
||||||
|
Loading…
Reference in New Issue
Block a user