Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

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

Open
#76 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
52/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
cpp
Domain
tooling

Research direction

Start in irange.hpp at the assertions around lines 210 and 219, then inspect the existing test_irange cases. Verify the reported calls produce empty ranges without iterating, and add or update tests so these cases complete with zero iterations.

Written by the indexing model from the issue text.

Description

the simple example irange(-5) I would expect to be an empty range, i.e.

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

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
Dominant language
C++
Stars
45
Forks
104
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from boostorg/range

All issues in boostorg/range

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.