Skip to content
This repository was archived by the owner on Aug 23, 2024. It is now read-only.

Are checked adds necessary? #5

@jrozner

Description

@jrozner

There are a number of places where the address is added to an offset (symbolic address mode, jxx instructions, etc.) There's already been one issue discovered and fixed caused by bad casting + arithmetic that caused an i16 MAX_I16 overflow during computation. Checked add is probably the correct way to make sure at runtime that nothing bad happens but since we're casting up to i64 to do math and both values are at most MAX_I16 or MAX_U16 there should be plenty of space to work with. If it's found to not be true the following is probably the correct way to handle it:

let val = ((addr as i64).checked_add(*i as i64)).unwrap_or(0) as u64;

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions