Bug 43841
| Summary: | SegmentedVector::operator== typo | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | andreyf <andrey154> |
| Component: | JavaScriptCore | Assignee: | Nobody <webkit-unassigned> |
| Status: | RESOLVED FIXED | ||
| Severity: | Normal | CC: | barraclough, darin, ggaren |
| Priority: | P2 | ||
| Version: | 528+ (Nightly build) | ||
| Hardware: | All | ||
| OS: | All | ||
andreyf
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
| Attachments | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Darin Adler
Looks bad! I wonder what the symptom is.
Geoffrey Garen
It looks like the operator isn't used. I'd suggest removing it.
andreyf
(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
Geoffrey Garen
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.
Darin Adler
Yes, lets remove the function as Geoff suggests.
Gavin Barraclough
Fixed in r88892. (These operators are used by the DFG JIT).
Gavin Barraclough
*** Bug 56289 has been marked as a duplicate of this bug. ***