diff options
author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2019-02-18 21:53:53 +0100 |
---|---|---|
committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2019-02-25 21:02:14 +0100 |
commit | 40dbb39225621021d27d4727d784ee40a1344418 (patch) | |
tree | ee1ebf27c169afee982bb6fadb49c961fd9990a0 | |
parent | 441c2847ad4b73b2b45a4e4e596a3f98908e9772 (diff) | |
download | sparse-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.c | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -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)) { |