[PATCH] evaluate: sizeof(bool) could be larger than sizeof(char)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The C standard doesn't require that the size of a _Bool is 1,
its size is implementation defined.

However, in evaluate_sizeof() the assumption is made that
a bool is the same size as a char.

Fix this wrong assumption by using the existing bits_in_bool.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
---
 evaluate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/evaluate.c b/evaluate.c
index e4d6b737d..71e38166f 100644
--- a/evaluate.c
+++ b/evaluate.c
@@ -2216,7 +2216,7 @@ static struct symbol *evaluate_sizeof(struct expression *expr)
 	if (is_bool_type(type)) {
 		if (Wsizeof_bool)
 			warning(expr->pos, "expression using sizeof _Bool");
-		size = bits_in_char;
+		size = bits_to_bytes(bits_in_bool);
 	}
 
 	if (is_function(type->ctype.base_type)) {
-- 
2.20.1




[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux