@@ -14,7 +14,7 @@ int max_alignment = 16;
/*
* Integer data types
*/
-int bits_in_bool = 1;
+int bits_in_bool = 8;
int bits_in_char = 8;
int bits_in_short = 16;
int bits_in_int = 32;
@@ -41,6 +41,16 @@ static struct same_offset not_an_error = {
.field1 = { },
.field2 = 0
};
+
+/*
+ * _Bools generally take a whole byte, so ensure that we can initialize
+ * them without spewing a warning.
+ */
+static _Bool boolarray[3] = {
+ [0] = 1,
+ [1] = 1,
+};
+
/*
* check-name: Initializer entry defined twice
*
@@ -4,9 +4,5 @@ static int a(void)
}
/*
* check-name: sizeof(_Bool) is valid
- * check-description: sizeof(_Bool) was rejected because _Bool is not an even
- * number of bytes
- * check-error-start
-sizeof-bool.c:3:16: warning: expression using sizeof bool
- * check-error-end
+ * check-description: sizeof(_Bool) is valid
*/
This reverts commit 65be24b8ddf54164ff25febfd3d5f9c26ae3877d. bits_in_bool was originally set to 1 bit, and then was reset to 8 to work around some issues with LLVM. Once those were resolved it was apparently set back to being 1 bit. The problem here is that, at least with GCC on x86_64, a _Bool always seems to be end up being 8 bits (which makes sense -- how would you get a pointer to it otherwise?). If you declare and initialize an array like this: static _Bool boolarray[3] = { [0] = 1, [1] = 1, }; ...you get warnings like this (which are bogus): ./test.c:2:10: warning: Initializer entry defined twice ./test.c:3:10: also defined here The bits_to_bytes conversion ends up wrong because it relies on integer division, and that causes the above bogus warning. Reset it back to 8 bits, and add a validation test that creates the above array to ensure that we don't end up breaking it again. Cc: Pekka Enberg <penberg@kernel.org> Signed-off-by: Jeff Layton <jlayton@primarydata.com> --- target.c | 2 +- validation/initializer-entry-defined-twice.c | 10 ++++++++++ validation/sizeof-bool.c | 6 +----- 3 files changed, 12 insertions(+), 6 deletions(-)