aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/evaluate.c
diff options
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2021-02-24 22:34:26 +0100
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2021-02-24 22:50:16 +0100
commit567dfd4f41d732043876dadc0697ba3b540066da (patch)
tree5e8de2fb9086ae36a7b0f461dbc0aac117b503fa /evaluate.c
parent60c1f2706e30eacc29296e6cb5d9327c85a01340 (diff)
downloadsparse-dev-567dfd4f41d732043876dadc0697ba3b540066da.tar.gz
fix eval of the assignment of a non-restricted value to a restricted variable
Assignment to restricted variables are severely ... restricted. Nevertheless, one value is always fine because it has always the same bit representation: 0. So, 0 is accepted unconditionally but this creates a problem because the type of this 0 needs to be adjusted. Otherwise 0 (int) is assigned as-is even on restricted variable with a different bit-length. Fix this by casting the value to the target type before accepting it. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'evaluate.c')
-rw-r--r--evaluate.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/evaluate.c b/evaluate.c
index 41871e18..a661027f 100644
--- a/evaluate.c
+++ b/evaluate.c
@@ -1442,7 +1442,7 @@ static int check_assignment_types(struct symbol *target, struct expression **rp,
if (sclass & TYPE_FOULED && unfoul(s) == t)
goto Cast;
if (!restricted_value(*rp, target))
- return 1;
+ goto Cast;
if (s == t)
return 1;
} else if (!(sclass & TYPE_RESTRICT))