This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch] : Improve std::search on v7
Chris Jefferson <caj@cs.york.ac.uk> writes:
| Gabriel Dos Reis wrote:
| > chris jefferson <caj@cs.york.ac.uk> writes:
| >
| > | This is quite a simple patch that does a few things.
| > |
| > | 1) Adds a new version of a more generic bind2nd to predefined_ops.h
| > | (if anyone has the old copy, it should be dumped and the file replaced
| > | with a clean CVS version, then this patch applied.
| > |
| > | This uses the "Empty Base Optimization" to avoid PR20408, but even if
| >
| >
| > I think we have already proven in the past that non-careful uses of
| > EBO change program semantics. Think of a function object with virtual
| > operator().
| >
| Hmm.. out of interest, could you give an example of exactly how this can
| break? I've heard of such problems with EBO, but couldn't find a
| concrete example of it breaking, and failed to do so myself (possibly a
| lack of imagination).
I remember that someone raised that issue ont this list (having to do
with Allocators) for containers, and eventually we reworked the
container implementation. Basically, when a class is polymorphic,
deriving, internally in our implementation, from it can change
semantics of user program.
How does your patch perform with this comparator?
#include <typeinfo>
struct CompareInt {
virtual bool operator()(int i, int j) const
{
// Derived classes must override this function.
assert(typeid(*this) == typeid(Compare));
return i == j;
}
};
-- Gaby