fork download
  1. #define _GLIBCXX_DEBUG 1
  2. #define _GLIBCXX_DEBUG_PEDANTIC 1
  3. #define _FORTIFY_SOURCE 2
  4.  
  5. #include <bits/stdc++.h>
  6.  
  7. #define all(x) (x).begin(),(x).end()
  8.  
  9. using vi = std::vector<int>;
  10.  
  11. int main() {
  12. vi arr{1,2,3,4};
  13. auto ptr = arr.begin();
  14. arr.push_back(5);
  15. std::cout << *ptr << std::endl;
  16. }
Runtime error #stdin #stdout #stderr 0s 4524KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
/usr/include/c++/8/debug/safe_iterator.h:270:
Error: attempt to dereference a singular iterator.

Objects involved in the operation:
    iterator "this" @ 0x0x7fff25afaf10 {
      type = __gnu_debug::_Safe_iterator<__gnu_cxx::__normal_iterator<int*, std::__cxx1998::vector<int, std::allocator<int> > >, std::__debug::vector<int, std::allocator<int> > > (mutable iterator);
      state = singular;
      references sequence with type 'std::__debug::vector<int, std::allocator<int> >' @ 0x0x7fff25afaf40
    }