Incorrect behavior of reversed_range with -O2 g++ option
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 42/100
Research direction
Start by compiling the example code from the issue with g++ or clang++ at -O0 and -O2, then inspect the reversed_range entry points used by boost::adaptors::reverse. Confirm that the optimized build produces the expected 2 1 0 output, and add a regression test covering the reported compilers and optimization level.
Written by the indexing model from the issue text.
Description
Example code:
#include "boost/iterator/counting_iterator.hpp"
#include "boost/range/iterator_range.hpp"
#include "boost/range/adaptor/reversed.hpp"
#include <iostream>
int main(int, char **)
{
using iterator = boost::counting_iterator<int>;
using iterator_range = boost::iterator_range<iterator>;
using reversed_range = boost::reversed_range<iterator_range>;
iterator first(0), last(3);
iterator_range range(first, last);
reversed_range r_range = boost::adaptors::reverse(range);
reversed_range::const_iterator it = r_range.begin();
for (; it != r_range.end(); ++it)
std::cout << *it << " ";
std::cout << std::endl;
}
Compile with: -O2
Output: 3 integer numbers, different from run to run, similar to
22007 22007 22007
(with g++)
or
-1807142200 0 0
(with clang++)
When compiled with -O0 produces the correct output:
2 1 0
Reproducible with:
Boost 1.67.0, 1.68.0
g++ 6.4.0, 7.3.0, 8.2.0; clang++ 7.0.0-3
CPU architecture: x86-64 (Intel Xeon)
- Dominant language
- C++
- Stars
- 45
- Forks
- 104
- PR merge metrics
- No merged PRs in 30d
Getting set up
We have not checked this project's setup files yet. Start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from boostorg/range
-
Difficulty 1/5 Under an hour Newbie friendliness 65/100
-
Difficulty 1/5 Under an hour Newbie friendliness 70/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 35/100
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
-
Difficulty 3/5 1-2 days Newbie friendliness 38/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
category:port-update
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
CLI jira shell completion
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day