Closed tsung-wei-huang closed 5 years ago
Here is an example:
#include <iostream>
#include "plf_list.h"
int main() {
plf::list<int> list1;
list1.emplace_back(1);
list1.emplace_back(2);
plf::list<int> list2 = std::move(list1);
list1.emplace_back(3); // Reuse the moved list will cause segmentation fault
}
My GCC version is 7.4.0 and the compilation command I use:
g++ -std=c++17 example.cpp
Thanks!
Alright, will fix
Fixed- and have included that test in the test suite - thanks. The move assignment operator was doing the right thing, just not the move constructor.
BTW your assumptions about what you can do with a moved container can be incorrect depending on circumstance - the standard requires that destruction works on a moved type but that's it. However most containers tend to follow the core guidelines and make the container clear()'d, and the STL does this, so I should be doing it too! More info if interested: https://stackoverflow.com/questions/9168823/reusing-a-moved-container http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rc-move-semantic
Hi I suspected the move semantics are not handled properly. We are using your project but it crashed when constructing a list with move constructor.