-
Notifications
You must be signed in to change notification settings - Fork 182
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
Conversation
There was a problem hiding this 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}} |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this 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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks.
This PR adds expected warnings and errors to tests that result from inferring rvalue bounds for conditional expressions (in checkedc-clang/924).