diff options
author | Thomas Haller <thaller@redhat.com> | 2017-12-11 16:24:42 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2017-12-15 11:48:38 +0100 |
commit | c1f1fe8001770a58806c412285777e4cc65529c6 (patch) | |
tree | 5d943fe17584065919661a8df4d0edce753c6c2e /m4 | |
parent | 3c9889ee4c261a0a30af3bb6994377203df60fa5 (diff) |
build: add "-Wvla" to warn about uses of variable-length arrays
We don't use them, so add a compiler warning about their use.
I think they are annoying, because sizeof(x) and typeof(x) might
evaluate at runtime. Especially the typeof() extension is useful
for macros, but behaves badly with variable-length arrays due to
running code at runtime.
But the worst is, G_STATIC_ASSERT() is implemented by declaring
an array of negative length. Usually, the checked condition should
be a compile time constant, but with VLAs the compiler would not evaluate
the static-assert at compile time and instead accept it silently. It's easy
to mess up static asserts to wrongly have a non-constant condition,
especially when the static-assert is used inside a macro.
Just say no.
Diffstat (limited to 'm4')
-rw-r--r-- | m4/compiler_options.m4 | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/m4/compiler_options.m4 b/m4/compiler_options.m4 index ccb51f5e6..c0b07e5b4 100644 --- a/m4/compiler_options.m4 +++ b/m4/compiler_options.m4 @@ -79,6 +79,7 @@ if test "$GCC" = "yes" -a "$set_more_warnings" != "no"; then -Wshift-negative-value \ -Wstrict-prototypes \ -Wundef \ + -Wvla \ -Wno-duplicate-decl-specifier \ -Wno-format-truncation \ -Wno-format-y2k \ |