Skip to content

Allow assume bounds casts for function pointers #861

Closed
@secure-sw-dev-bot

Description

@secure-sw-dev-bot

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


Fixes #855

This PR allows _Assume_bounds_casts to be used to convert an unchecked function pointer (including NULL) to a checked function pointer. The unchecked function pointer pointee type must be compatible with the checked function pointer pointee type.

For example, this will be allowed:

void test(int(*f)(int)) {
    ptr<int(int)> safe = _Assume_bounds_cast<ptr<int(int)>>(f);
}

This will not be allowed:

void test(int(*f)(int)) {
    ptr<void(double)> bad = _Assume_bounds_cast<ptr<void(double)>>(f);
}

Testing:

  • Added tests in checkedc/407
  • Passed manual testing on Windows
  • Passed automated testing on Windows/Linux

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