[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gnash-commit] [SCM] Gnash branch, objecturi, updated. a3e2d11b545fc

From: Benjamin Wolsey
Subject: Re: [Gnash-commit] [SCM] Gnash branch, objecturi, updated. a3e2d11b545fcdb326df4229e9524bf27d4fc9bd
Date: Thu, 23 Sep 2010 09:38:33 +0200

> > 
> > Ouch, this introduced a weird bug: 'this' is not found (in swf7+)
> So, this was the equals() function defined _before_ the
> equality operator used in it.
> Compiler was syntetizing another equality operator based on the
> "safe" (how much safe!) bool operator...

If you introduce a conversion to bool, there will always be an equality

You can prevent it by defining operator!() instead of conversion to
bool, but that restricts the way you can use the class to if(!uri), but
not if (uri).

The properly safe bool idiom:

struct ObjectURI
    typedef void(ObjectURI::*Safe)() const;
    void non_comparable() const {};
    operator Safe() const {
        return true ? &ObjectURI::non_comparable : 0;


prevents automatic less-than comparison, which operator const void*
doesn't, but it still allows equality comparison!

I see the branch has

operator<(const ObjectURI&, const ObjectURI&);

defined, but I suspect anyone using operator>() instead would currently
get the bogus comparison of const void*s.


Free Flash, use Gnash

Benjamin Wolsey, Software Developer -
C++ and Open-Source Flash blog -


Attachment: signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil

reply via email to

[Prev in Thread] Current Thread [Next in Thread]