Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_Assume_bounds_cast added with checked array type #728

Open
kyleheadley opened this issue Oct 18, 2021 · 1 comment
Open

_Assume_bounds_cast added with checked array type #728

kyleheadley opened this issue Oct 18, 2021 · 1 comment
Labels
benchmark failure A bug causing a failure in our nightly benchmark tests cast

Comments

@kyleheadley
Copy link
Member

The icecast benchmarks includes a few copies of this error:

md5.c:122:112: error: expected _Array_ptr type
          MD5Transform(_Assume_bounds_cast<uint32_t _Checked[4]>(ctx->buf, ...),...);
                                           ^

According to the spec, _Assume_bounds_cast must use a checked pointer type (_Ptr,_Array_ptr, or _Nt_array_ptr).

In this case, both MD5Transform and ctx->buf use identical uint32_t buf[4] types in the source. I assume ctx could not be verified, hence the cast.

We probably need a new code path for sized arrays, if it doesn't already exist.

@kyleheadley kyleheadley added cast benchmark failure A bug causing a failure in our nightly benchmark tests labels Oct 18, 2021
@john-h-kastner
Copy link
Collaborator

john-h-kastner commented Oct 18, 2021

Here's a concrete example:

void test(int a[1]) {}
void caller() {
  int *b = 1;
  test(b);
}

The call becomes test(_Assume_bounds_cast<int _Checked[1]>(b, bounds(unknown)));. The target type of the cast should instead be _Array_ptr<int>. This cast would be valid because the checked array type int _Checked[1] in a function parameter decays to a checked array pointer type _Array_ptr<int>.

@mattmccutchen-cci mattmccutchen-cci changed the title _Assume_bounds_cast added with non-Ptr type variable _Assume_bounds_cast added with checked array type Oct 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
benchmark failure A bug causing a failure in our nightly benchmark tests cast
Projects
None yet
Development

No branches or pull requests

2 participants