Skip to content

Extend dynamic_bounds_cast to handle relative alignment. #326

@secure-sw-dev-bot

Description

@secure-sw-dev-bot

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions