Skip to content

Commit f649c47

Browse files
authored
Merge pull request #5723 from tautschnig/single-bit
C front-end: hide our use of single-bit bool within sizeof
2 parents 276b8d7 + 5f86851 commit f649c47

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

regression/ansi-c/sizeof4/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
KNOWNBUG
1+
CORE
22
main.c
33

44
^EXIT=0$

src/ansi-c/c_typecheck_expr.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -950,7 +950,14 @@ void c_typecheck_baset::typecheck_expr_sizeof(exprt &expr)
950950
}
951951
else
952952
{
953-
type.swap(to_unary_expr(expr).op().type());
953+
const exprt &op = to_unary_expr(as_const(expr)).op();
954+
// This is one of the few places where it's detectable
955+
// that we are using "bool" for boolean operators instead
956+
// of "int". We convert for this reason.
957+
if(op.type().id() == ID_bool)
958+
type = signed_int_type();
959+
else
960+
type = op.type();
954961
}
955962

956963
exprt new_expr;

0 commit comments

Comments
 (0)