Skip to content

Target a single assignment in bounds checking error messages #889

Closed
@secure-sw-dev-bot

Description

@secure-sw-dev-bot

This issue was copied from checkedc/checkedc-clang#893


  • In bounds checking related diagnostic messages, highlight the assignment within a top-level statement that causes the error or warning. This PR considers two types of bounds checking error messages for a variable V:
    1. The compiler cannot prove or can disprove the declared bounds for V are valid after an assignment to a variable in the bounds of V; and
    2. The inferred bounds of V become unknown after an assignment to a variable used in the declared bounds for V.
  • Print 'assignment', 'increment', 'decrement' or 'initialization' in the error message depending on the "type" of the target expression.

An example

array_ptr<int> p : count(len) = ...;
other = 0, len = len * 2;

Error message before the change (highlight the whole statement):

error: inferred bounds for 'p' are unknown after statement
  other = 0, len = len * 2;
  ^~~~~~~~~~~~~~~~~~~~~~~~~

After the change (blame the embedded assignment that caused the error; print 'assignment' instead of 'statement'):

error: inferred bounds for 'p' are unknown after assignment
  other = 0, len = len * 2;
             ^~~~~~~~~~~~~

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions