This is an archive of the discontinued LLVM Phabricator instance.

[ADT] Remove illegal comparison of singular iterators from SmallSetTest
ClosedPublic

Authored by eush on Oct 27 2018, 3:54 AM.

Details

Summary

This removes the assertion that a copy of a moved-from SmallSetIterator
equals the original, which is illegal due to SmallSetIterator including
an instance of a standard std::set iterator.

C++ [iterator.requirements.general] states that comparing singular
iterators has undefined result:

Iterators can also have singular values that are not associated with
any sequence. [...] Results of most expressions are undefined for
singular values; the only exceptions are destroying an iterator that
holds a singular value, the assignment of a non-singular value to an
iterator that holds a singular value, and, for iterators that satisfy
the Cpp17DefaultConstructible requirements, using a value-initialized
iterator as the source of a copy or move operation.

This assertion triggers the following error in the GNU C++ Library in
debug mode under EXPENSIVE_CHECKS:

/usr/include/c++/8.2.1/debug/safe_iterator.h:518:
Error: attempt to compare a singular iterator to a singular iterator.

Objects involved in the operation:
    iterator "lhs" @ 0x0x7fff86420670 {
      state = singular;
    }
    iterator "rhs" @ 0x0x7fff86420640 {
      state = singular;
    }

Diff Detail

Repository
rL LLVM

Event Timeline

eush created this revision.Oct 27 2018, 3:54 AM
eush edited the summary of this revision. (Show Details)Oct 27 2018, 3:56 AM
dblaikie accepted this revision.Oct 27 2018, 11:42 AM

sounds good - thanks!

This revision is now accepted and ready to land.Oct 27 2018, 11:42 AM
fhahn accepted this revision.Oct 27 2018, 12:01 PM

Thanks!

eush added a comment.Oct 30 2018, 3:45 AM

Can you commit this change? I don't have commit access.

I can commit it tomorrow.

This revision was automatically updated to reflect the committed changes.
fhahn added a comment.Oct 31 2018, 5:18 AM

Committed, thank you very much for the patch!