This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libstdc++/85828] std::shuffle tries to swap element with itself


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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2018-05-18
           Assignee|unassigned at gcc dot gnu.org      |redi at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---

#include <vector>
#include <random>
#include <algorithm>

struct Type {
        std::vector<int> ints;
};

int main() {
        std::vector<Type> intVectors = {{{1}}, {{1, 2}}};
        std::shuffle(intVectors.begin(), intVectors.end(), std::mt19937());
}

$ g++ self.cc -D_GLIBCXX_DEBUG
$ ./a.out
/usr/include/c++/7/debug/safe_container.h:83:
Error: attempt to self move assign.

Objects involved in the operation:
    sequence "this" @ 0x0x12e7ee8 {
      type = __gnu_debug::_Safe_container<std::__debug::vector<int,
std::allocator<int> >, std::allocator<int>, __gnu_debug::_Safe_sequence, true>;
    }
Aborted (core dumped)

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]