Skip to content

Conversation

@ibuclaw
Copy link
Member

@ibuclaw ibuclaw commented Feb 10, 2018

Both can never result in a bounds error, and so don't generate code to check for it.

Follow-up of #7682.

This means that code like:

auto sl = arr[n .. $])

Will only check that n <= $.

For smart optimizers, the conditions 0 <= $ and $ <= $ would be removed as dead code anyway. This just means that the glue/backend never generates the test in the first place.

Both can never result in a bounds error, and so don't generate code to check for it.
@dlang-bot
Copy link
Contributor

Thanks for your pull request, @ibuclaw!

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

@d-random-contributor
Copy link

Do we have xfail tests for

a[1..0]
a[$..0]

to not overdo with shortcuts?

@ibuclaw
Copy link
Member Author

ibuclaw commented Feb 10, 2018

Do we have xfail tests for

There's plenty. Anyway that's a different slicing flag to the one being tweaked here. Array bounds consists of two checks, is upper is in bounds, and is lower less than or equal to upper.

This only elides the first test. But again, a smart backend optimizer is already doing this, and so this patch is only removing that extra work done to get the exact same result.

@dlang-bot dlang-bot merged commit 83b495a into dlang:master Feb 10, 2018
@ibuclaw ibuclaw deleted the varconstants branch February 10, 2018 18:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants