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

Update tests for conditional rvalue bounds #422

Merged
merged 1 commit into from
Nov 10, 2020
Merged

Conversation

kkjeer
Copy link
Contributor

@kkjeer kkjeer commented Oct 20, 2020

This PR adds expected warnings and errors to tests that result from inferring rvalue bounds for conditional expressions (in checkedc-clang/924).

Copy link
Member

@dtarditi dtarditi left a comment

Choose a reason for hiding this comment

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

I am confused why these changes are necessary. It seems like something unexpected is happening to bounds for conditional expressions that evaluate to an nt_array_ptr and involve implicit casts for the arms.

@@ -514,7 +514,7 @@ extern void check_condexpr(int val) {
array_ptr<int> t5 = val ? r : 0;
array_ptr<int> t5a = val ? v : 0;
array_ptr<int> t6 = val ? 0 : r;
nt_array_ptr<int> t6a = val ? 0 : v;
nt_array_ptr<int> t6a = val ? 0 : v; // expected-warning {{cannot prove declared bounds for 't6a' are valid after initialization}}
Copy link
Member

Choose a reason for hiding this comment

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

I am surprised by this. I would have expected 0 to have bounds(any), the bounds for v to be count(5), and the overall bounds for the two arms to be count(5). What are the actual bounds the compiler is inferring for the two arms?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The compiler infers bounds(any) for 0, bounds(v, v + 5) for v, and bounds(v, v + 5) as the overall bounds for the two arms. v and t6a are not known to be equal, so the compiler cannot prove that bounds(v, v + 5) imply bounds(t6a, t6a + 0).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Created checkedc-clang/934 to track this follow-up work.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for the explanation and opening the issue to track this. I agree that this should be handled as a separate follow-up issue.

Copy link

@mgrang mgrang left a comment

Choose a reason for hiding this comment

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

LGTM, unless David has more comments.

@mgrang mgrang requested a review from sulekhark November 7, 2020 04:31
Copy link
Member

@dtarditi dtarditi left a comment

Choose a reason for hiding this comment

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

Looks good, thanks.

@kkjeer kkjeer merged commit 6779403 into master Nov 10, 2020
@kkjeer kkjeer deleted the conditional-rvalue-bounds branch November 10, 2020 07:30
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.

None yet

3 participants