Skip to contentSkip to conversation

univ-init: set default to -Wno-universal-initializer

PATCH New Luc Van Oostenryck 1 participant 1 message May 30, 2020 Sparse checker

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 univ-init: set default to -Wno-universal-initializer

'{ 0 }' is the standard idiom for the universal zero initializer '{ }'.

But if the '0' is taken literally, warnings can be issued, for exemple for 'using 0 as NULL pointer' or for 'using a positional initializer' when the attribute 'designated_init' is used.
These warnings were not intended to be issued for this initializer and are confusing and annoying when people have to use or want to use standard code or ignore that '{ }' is fine to use with GCC, clang or Sparse.

So, set sparse default to -Wno-universal-initializer, suppressing any warnings caused by using '{ 0 }' instead of '{ }'.

Reference: https://lore.kernel.org/git/[email protected]/
Reference: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95379

---
 lib.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib.c +1 -1
index 9ee8d3cf6b21..37c09d914c56 100644
@@ -295,7 +295,7 @@ int Wtransparent_union = 0;
 int Wtypesign = 0;
 int Wundef = 0;
 int Wuninitialized = 1;
-int Wuniversal_initializer = 1;
+int Wuniversal_initializer = 0;
 int Wunknown_attribute = 0;
 int Wvla = 1;
 
Signature · 1 line
2.26.2