-
Notifications
You must be signed in to change notification settings - Fork 19
Description
This issue was copied from checkedc/checkedc-clang#327
When a value is cast using dynamic_bounds_cast, we need some additional checks for relative alignment.
Suppose we have a dynamic_bounds_cast with the form dynamic_bounds_cast(e1, bounds(e2, e3)) where e1 evaluates to a value v, e2 evaluates to a value a, and e3 evaluates to a value b, and the target relative alignment is k. Given a value v with target bounds (a, b) with a relative alignment of k, we need to check that a, b, and v are all relatively aligned: (b - a) must be a multiple of k and v - a must be multiple of k. If k is 1, there is no work to do.
Second, if the source destination alignment is not an integral multiple of the destination alignment, we need to take into account that the bounds may be misaligned. Specifically given an inferred bounds of (lb, ub) and a target bounds of (a, b) and a target alignment of k, we need to check that (lb >= a && b + k - 1<= ub.