KEMBAR78
gh-96678: A few asserts to demonstrate undefined behaviour in 3.11 by matthiasgoergens · Pull Request #19 · matthiasgoergens/cpython · GitHub
Skip to content

Conversation

@matthiasgoergens
Copy link
Owner

@matthiasgoergens matthiasgoergens commented Sep 8, 2022

Backported from my asserts for main.

See python#96678

@matthiasgoergens matthiasgoergens changed the title A few asserts to demonstrate undefined behaviour A few asserts to demonstrate undefined behaviour in 3.11 Sep 8, 2022
@matthiasgoergens matthiasgoergens changed the title A few asserts to demonstrate undefined behaviour in 3.11 gh-96678: A few asserts to demonstrate undefined behaviour in 3.11 Sep 8, 2022
const unsigned char *bytes = (const unsigned char *)p;
do {
assert(0 <= x);
assert(x <= (LLONG_MAX>>8));
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one should be LONG_MAX.


cp = fragment->buf;
for (i = 0; i < fragment->len*width; i += width) {
assert(0 <= st_ulaw2linear16(*cp));
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'd also need to make sure that we don't left-shift the signed int too far.

Here and in the rest of this file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant