This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Error in stl?
- From: Anders Fugmann <afu at fugmann dot net>
- To: gcc at gcc dot gnu dot org
- Date: Thu, 19 Aug 2004 13:42:32 +0000
- Subject: Error in stl?
Hi,
It seems that there is an error in the STL implementation in gcc version
3.3, 3.4 and 3.5, as it cannot compile when using
const_reverse_iterators to iterate over a simple vector.
The following code exposes the problem:
===========
#include <vector>
void test()
{
std::vector<int> v;
int sum = 0;
// This works as expected.
for (std::vector<int>::const_iterator i = v.begin();
i != v.end(); ++i) {
sum += *i;
}
// This also works.
for (std::vector<int>::reverse_iterator i = v.rbegin();
i != v.rend(); ++i) {
sum += *i;
}
// This cannot compile.
for (std::vector<int>::const_reverse_iterator i = v.rbegin();
i != v.rend(); ++i) {
sum += *i;
}
}
===============
When trying to compile the above, I get the error:
test.cc:18: error: no match for 'operator!=' in 'i != std::vector<_Tp,
_Alloc>::rend() [with _Tp = int, _Alloc = std::allocator<int>]()'
(is the const version of rend() missing?)
Should I file a report in bugzilla, or am i misinterpreting the c++
programming language?
Regards
Anders Fugmann