Closed sim642 closed 2 years ago
Could this cause issues with non-c99 code that does not expose a bool type?
I don't think it can in Goblint because in other cases it could also return smaller ikinds than the program variables have, e.g. char
for some value involved in int
-typed variables, but that doesn't happen (it would lead to a mismatching ikind error), I suppose because we eventually cast this to a type that the program actually uses.
Another reason why this shouldn't be an issue is that we just use it for def_exc range, which is essentially an interval that may be smaller than the type's range if only small values are ever stored in such variable. The ID.t
tracks the ikind (coming from the program) separately from def_exc range, so the range being tighter should be fine.
The only way I see this being a problem is if intKindForValue
is used explicitly to generate some CIL AST for outputting as C code, then that ends up with _Bool
being used in a program that originally might've been C99. But the same happens with any other C11 feature if used in such way.
Upstream fix for the second issue in https://github.com/goblint/analyzer/pull/827.
Technically the fix could even be moved up into
truncateCilint
, whereIBool
is already specially handled, but for some reason as never truncating. SincetruncateCilint
is transitively used all over the place, I didn't want to change it as the old logic might be there for some reason.fitsInInt
is used little enough to see that it isn't used withIBool
anywhere previously, so no accidental behavior changes would occur.