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

Fix compiler warnings for conditional expression bounds #934

Open
kkjeer opened this issue Nov 6, 2020 · 0 comments
Open

Fix compiler warnings for conditional expression bounds #934

kkjeer opened this issue Nov 6, 2020 · 0 comments
Assignees
Labels
work item This labels issues that are not exactly bugs but are about improvements.

Comments

@kkjeer
Copy link
Contributor

kkjeer commented Nov 6, 2020

Consider a conditional expression whose rvalue bounds depend on a variable that appears in only one arm:

array_ptr<int> y : count(5) = 0;
array_ptr<int> x : count(5) : cond ? y : 0;

The compiler infers bounds(y, y + 5) for the left arm, bounds(any) for the right arm, and bounds(y, y + 5) for the conditional expression cond ? y : 0. These bounds are used to validate the declared bounds bounds(x, x + 5) of x. Since it is not known that x and y are equivalent, this results in a compiler warning: "cannot prove declared bounds of 'x' are valid after initialization".

The logic outlined in the language spec for handling uses of temporaries bound in only one arm may be generalized to handle this case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
work item This labels issues that are not exactly bugs but are about improvements.
Projects
None yet
Development

No branches or pull requests

2 participants