Bug 43841 - SegmentedVector::operator== typo
Summary: SegmentedVector::operator== typo
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords:
: 56289 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-08-11 03:02 PDT by andreyf
Modified: 2011-08-12 16:10 PDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description andreyf 2010-08-11 03:02:13 PDT
WTF::SegmentedVector::operator== (in file webkit\JavaScriptCore\wtf\SegmentedVector.h:70) has typo:
        bool operator==(const Iterator& other) const
        {
            return (m_index == other.m_index && m_segment = other.m_segment && &m_vector == &other.m_vector); // HERE: m_segment _=_ other.m_segment
        }

This should be:
        bool operator==(const Iterator& other) const
        {
            return (m_index == other.m_index && m_segment == other.m_segment && &m_vector == &other.m_vector);
        }

Because normaly operator== should be ! operator!=.

        bool operator!=(const Iterator& other) const
        {
            return (m_index != other.m_index || m_segment != other.m_segment || &m_vector != &other.m_vector); // NOTE: m_segment _!=_ other.m_segment 
        }

I don't know consequences of this.

Kind regards,
Andrey
Comment 1 Darin Adler 2010-08-11 08:58:23 PDT
Looks bad! I wonder what the symptom is.
Comment 2 Geoffrey Garen 2010-08-11 10:10:17 PDT
It looks like the operator isn't used. I'd suggest removing it.
Comment 3 andreyf 2010-08-12 00:27:04 PDT
(In reply to comment #1)
> Looks bad! I wonder what the symptom is.

Darin, unfortunately, this was found by my code intrumentation utility and i don't have time to compose a unit test to reproduce erroneous behaviour.
I promise to try later.
Why don't change this to something like:
        bool operator==(const Iterator& other) const
        {
            return ! operator!= (other);
        }
It will not consume much code space and provide full external interface to SegmentedVector. 

Kind regards,
Andrey
Comment 4 Geoffrey Garen 2010-08-12 11:37:55 PDT
I'm not keen on having unused / untested code in the tree. It leads to bitrot like this.

If you plan on using this function, that's a different story.
Comment 5 Darin Adler 2010-08-12 12:22:38 PDT
Yes, lets remove the function as Geoff suggests.
Comment 6 Gavin Barraclough 2011-06-14 18:58:08 PDT
Fixed in r88892.  (These operators are used by the DFG JIT).
Comment 7 Gavin Barraclough 2011-08-12 16:10:45 PDT
*** Bug 56289 has been marked as a duplicate of this bug. ***