boostorg / boostorg/range

irange makes non-emtpy ranges when first is greater than last

Open
#76 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
45
Forks
104
PR merge metrics
No merged PRs in 30d

Description

the simple example `irange(-5)` I would expect to be an empty range, i.e.
```cpp
int32_t end = -5;
int64_t count = 0;
for (int32_t i = 0; i < end; ++i)
// this line will never be reached
++count;
std::cout << count << std::endl; // 0

count = 0;
for (auto i : boost::irange(end))
// this should never be reached, but it will
// iterate past int32_t max until it reaches -5
++count;
std::cout << count << std::endl; // 4294967291
```

My expectations is the following tests should pass with no iterations, but many fail on asserts in the test but will be large ranges in release
```cpp
test_irange(-5);
test_irange(0, -5); // this fails on assert at irange.hpp#L210
test_irange(5, 10, -1); // this fails on assert at irange.hpp#L219
test_irange(10, 5, 1); // this fails on assert at irange.hpp#L219
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.