summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2019-02-18 21:53:53 +0100
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2019-02-25 21:02:14 +0100
commit40dbb39225621021d27d4727d784ee40a1344418 (patch)
treeee1ebf27c169afee982bb6fadb49c961fd9990a0
parent441c2847ad4b73b2b45a4e4e596a3f98908e9772 (diff)
downloadsparse-40dbb39225621021d27d4727d784ee40a1344418.tar.gz
evaluate: sizeof(bool) could be larger than sizeof(char)
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@gmail.com>
-rw-r--r--evaluate.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/evaluate.c b/evaluate.c
index e4d6b737..2fd19ff5 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) * bits_in_char;
}
if (is_function(type->ctype.base_type)) {