This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: rel_ops issues
- To: bkoz at redhat dot com (Benjamin Kosnik)
- Subject: Re: rel_ops issues
- From: Joe Buck <jbuck at racerx dot synopsys dot com>
- Date: Mon, 2 Apr 2001 17:03:50 -0700 (PDT)
- Cc: Gabriel dot Dos-Reis at cmla dot ens-cachan dot fr (Gabriel Dos Reis), Theodore dot Papadopoulo at sophia dot inria dot fr (Theodore Papadopoulo), libstdc++ at gcc dot gnu dot org
Ben writes:
> people can somebody please post
>
> 1) testsuite additions that clearly cause the regressions that joe is seeing
> 2) patches for the same
1) is in GNATS, reports 2405 and 2406, though the pages look garbled.
Test case for report 2405: compile
-----------------------------------------------------------------
#include <utility>
using std::rel_ops::operator!=;
#include <vector>
using std::vector;
void add_to(vector<int>& v, int x) { v.push_back(x);}
-----------------------------------------------------------------
Test case for report 2406:
----------------------------------------------------
#include <vector>
using std::vector;
struct foo {
int a;
};
bool operator==(const foo&, const foo&);
bool veq(const vector<foo>& a, const vector<foo>& b)
{
return a == b;
}
----------------------------------------------------
Because of legal problems I can't give you patches that have an
assignment, but I can describe one possible patches that I have
tested, it's pretty mechanical.
For 2405, we need to add additional partial specializations for
operator!= (and also <=, >=, and >) for __normal_iterator.
These partial specializations are for the case where both arguments
to operator!= are exactly the same. This means that there are two,
rather than three, typename arguments.
For 2406, the problem is with std::equal's use of operator!= (the
three-argument version).
There are two possible fixes. One is to add
using std::rel_ops::operator!=;
to the body of the function, ignoring Gaby's anguished screams. :-)
The other is to replace the occurrences of != with ! and == .
Actually, only one of the two != operators needs changing, the
one that does not operate on iterators.
I had thought that there would be lots of other cases like 2406.
But it seems that std::equal might be the only one; the other uses
of != that I can find in stl_algo and stl_algobase operate only
on iterators, and for those, __normal_iterator should supply
a definition or else the iterator will be a pointer and have a
valid !=. So I'm only asking for a fix to std::equal.