Bug 98466 - Debug Mode iterators for unordered containers do not implement N3644
Summary: Debug Mode iterators for unordered containers do not implement N3644
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libstdc++ (show other bugs)
Version: 11.0
: P3 normal
Target Milestone: 11.0
Assignee: François Dumont
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-12-28 20:14 UTC by Jonathan Wakely
Modified: 2024-03-11 20:38 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2020-12-29 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Wakely 2020-12-28 20:14:22 UTC
#define _GLIBCXX_DEBUG 1
#include <unordered_set>

int main()
{
  std::unordered_set<int>::iterator it{};
  it == it;
}

This aborts at runtime:

/home/jwakely/gcc/11/include/c++/11.0.0/debug/safe_iterator.h:461:
In function:
    bool __gnu_debug::operator==(const _Self&, const _Self&)

Error: attempt to compare a singular iterator to a singular iterator.

Objects involved in the operation:
    iterator "__lhs" @ 0x0x7ffc0e6d5940 {
      type = std::__detail::_Node_iterator<int, true, false> (mutable iterator);
      state = singular;
    }
    iterator "__rhs" @ 0x0x7ffc0e6d5940 {
      type = std::__detail::_Node_iterator<int, true, false> (mutable iterator);
      state = singular;
    }
Aborted (core dumped)


It seems that https://wg21.link/n3644 was not implemented for the debug mode iterators.
Comment 1 Dimitrij Mijoski 2021-01-27 14:25:27 UTC
This bug looks like a duplicate of bug 70303. The asserts presented there should be used on random-access iterators (vector, deque) to test if N3644 is implement.
Comment 2 Jonathan Wakely 2021-01-27 14:27:33 UTC
This was already fixed on master by r11-6682 05a30af3f237984b4dcf1dbbc17fdac583c46506
Comment 3 Dimitrij Mijoski 2021-01-27 14:43:10 UTC
(In reply to Jonathan Wakely from comment #2)
> This was already fixed on master by r11-6682
> 05a30af3f237984b4dcf1dbbc17fdac583c46506

Yes, that patch mostly fixes bug 70303, too. With that patch, the asserts presented in bug 70303 pass for vector<int>::iterator but not for deque<int>::iterator.
Comment 4 François Dumont 2021-02-08 05:54:07 UTC
Fully fixed