public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/114316] New: assert failure with _GLIBCXX_DEBUG and empty range of singular iterators passed std:: algorithm
@ 2024-03-12  9:05 ammiera at hotmail dot com
  2024-03-12  9:46 ` [Bug libstdc++/114316] assert failure with _GLIBCXX_DEBUG and empty range of singular iterators passed to " redi at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: ammiera at hotmail dot com @ 2024-03-12  9:05 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114316

            Bug ID: 114316
           Summary: assert failure with _GLIBCXX_DEBUG and empty range of
                    singular iterators passed std:: algorithm
           Product: gcc
           Version: 12.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ammiera at hotmail dot com
  Target Milestone: ---

Compiling the attached snippet with -D_GLIBCXX_DEBUG causes an assert to fire:

#include <map>
#include <algorithm>
#include <iterator>

int main()
{
    std::multimap<char, int>::iterator it1{};
    std::multimap<char, int>::iterator it2{};

    (void) (it1==it2); // OK
    (void) std::find_if(
        it1, it2, [](const auto& el) { return el.second == 8;});
}

The runtime error:

In function:
    constexpr _IIter std::find_if(_IIter, _IIter, _Predicate) [with _IIter = 
    gnu_debug::_Safe_iterator<_Rb_tree_iterator<pair<const char, int> >, 
    debug::multimap<char, int>, bidirectional_iterator_tag>; _Predicate = 
    main()::<lambda(const auto:16&)>]

Error: function requires a valid iterator range [first, last).

Objects involved in the operation:
    iterator "first" @ 0x7ffc275311a0 {
      type = std::_Rb_tree_iterator<std::pair<char const, int> > (mutable
iterator);
      state = singular;
    }
    iterator "last" @ 0x7ffc275311d0 {
      type = std::_Rb_tree_iterator<std::pair<char const, int> > (mutable
iterator);
      state = singular;
    }
Program terminated with signal: SIGSEGV

https://godbolt.org/z/e8xa5Eoqn

Tested with C++17 and C++20 mode.

Initially discussed on the mailing list:
https://gcc.gnu.org/pipermail/libstdc++/2024-March/058461.html

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-03-25 12:17 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-12  9:05 [Bug libstdc++/114316] New: assert failure with _GLIBCXX_DEBUG and empty range of singular iterators passed std:: algorithm ammiera at hotmail dot com
2024-03-12  9:46 ` [Bug libstdc++/114316] assert failure with _GLIBCXX_DEBUG and empty range of singular iterators passed to " redi at gcc dot gnu.org
2024-03-12 13:08 ` redi at gcc dot gnu.org
2024-03-17 15:42 ` cvs-commit at gcc dot gnu.org
2024-03-17 15:47 ` cvs-commit at gcc dot gnu.org
2024-03-20  6:07 ` fdumont at gcc dot gnu.org
2024-03-25 12:17 ` redi at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).