Incorrect behavior of reversed_range with -O2 g++ option
- Dominant language
- C++
- Stars
- 45
- Forks
- 104
- PR merge metrics
- No merged PRs in 30d
Description
Example code:
```c++
#include "boost/iterator/counting_iterator.hpp"
#include "boost/range/iterator_range.hpp"
#include "boost/range/adaptor/reversed.hpp"
#include
int main(int, char **)
{
using iterator = boost::counting_iterator;
using iterator_range = boost::iterator_range;
using reversed_range = boost::reversed_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)
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.