Opened 12 years ago
Closed 11 years ago
#5352 closed Bugs (duplicate)
BOOST_REVERSE_FOREACH does not work with boost::counting_iterator (gcc 4.5.0 and 4.5.2 using -O3)
| Reported by: | Owned by: | Dave Abrahams | |
|---|---|---|---|
| Milestone: | To Be Determined | Component: | iterator |
| Version: | Boost 1.46.0 | Severity: | Problem |
| Keywords: | BOOST_REVERSE_FOREACH, counting_iterator | Cc: |
Description
The following code:
#include <iostream>
#include "boost/foreach.hpp"
#include <boost/iterator/counting_iterator.hpp>
int main(int, char**) {
boost::counting_iterator<int> start(0), end(10);
std::pair<boost::counting_iterator<int>, boost::counting_iterator<int> > iterators(start, end);
std::cout << "Counting: ";
BOOST_REVERSE_FOREACH(int t, iterators) {
std::cout <<t<<" ";
}
std::cout << std::endl;
}
works fine with gcc-4.4.5 using -O3:
Counting: 9 8 7 6 5 4 3 2 1 0
but fails for gcc-4.5.0 and gcc-4.5.2 using -O3:
Counting: 70263556 70263556 70263556 70263556 70263556 70263556 70263556 70263556 70263556 70263556
System: i686-pc-linux-gnu
Change History (3)
comment:1 by , 12 years ago
comment:2 by , 12 years ago
| Component: | foreach → iterator |
|---|---|
| Owner: | changed from to |
Note:
See TracTickets
for help on using tickets.

This is a limitation of
counting_iteratorand not a bug of Boost.Foreach. See #2640.