Skip to content

Runtime check when the default relative alignment is overridden, needs to be added. #937

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

Closed
sulekhark opened this issue Nov 11, 2020 · 1 comment
Assignees
Labels
bug This labels issues that are bugs. priority:3 This labels bugs that are not very critical but still need to be addressed.

Comments

@sulekhark
Copy link
Contributor

Given below is a scenario (adapted and reduced from musl's memchr conversion to checkedc) where a runtime check (as per section 3.9.2 of the spec) needs to be added:

$ cat relalign.c
void test (const void *src : itype(_Array_ptr<const void>) byte_count(arg_n), unsigned int arg_n)
_Checked
{
        unsigned int n = arg_n;
        _Array_ptr<const unsigned char> s : bounds((_Array_ptr<const unsigned char>)src,
                                                   (_Array_ptr<const unsigned char>)src + arg_n)
                                          = (_Array_ptr<const unsigned char>) src;
        for (;  *s; s++, n--);
        if (n && *s) {
                _Array_ptr<unsigned int> w : bounds((_Array_ptr<const unsigned char>)src,
                                                    (_Array_ptr<const unsigned char>)src + arg_n) rel_align(unsigned char)
                                           = 0;
                for (w = (_Array_ptr<void>)s; n>=4 && *w; w++, n-=4);
        }
}
@sulekhark sulekhark self-assigned this Nov 11, 2020
@sulekhark sulekhark added bug This labels issues that are bugs. priority:3 This labels bugs that are not very critical but still need to be addressed. labels Jan 28, 2021
@sulekhark
Copy link
Contributor Author

This issue is covered by #329. Closing it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This labels issues that are bugs. priority:3 This labels bugs that are not very critical but still need to be addressed.
Projects
None yet
Development

No branches or pull requests

1 participant