id summary reporter owner description type status milestone component version severity resolution keywords cc 6778 directory_iterator and recursive_directory_iterator has inconsistent behavior with STL iterator when assignment operator=() is involved. Chih-Yao Hsieh Beman Dawes "For example, in std::vector, the following code shows that *vIterator_1 prints out intVec[1] and *vIteraotr_2 prints out intVec[0]. (The assignment operator=() does not make those two iterators link together...) {{{ std::vector intVec(10); intVec[1] = 1; std::vector::iterator vIterator_1 = intVec.begin(); // iterator assignment operator=() now get involved. std::vector::iterator vIterator_2 = vIterator_1; ++vIterator_1; // vIterator_2 does not increment. std::cout << ""*vIterator_1: "" << *vIterator_1; std::cout << ""*vIterator_2: "" << *vIterator_2; }}} On the other hand, the following example shows that dirIterator1->path() and dirIterator2->path() both contains '/home/user/test/2.txt' which is not consistent with STL iterator behavior. Since iterators behaves like pointers, after calling vIterator_2 = vIterator_1;, vIterator_2 and vIterator_1 should stays independent. The problem seems to be directory_iterator forgot to implement the copy constructor and assignment operator=(). {{{ // assuming that under /home/user/test, there are 1.txt and 2.txt boost::filesystem::path rootPath(""/home/user/test""); boost::filesystem::directory_iterator dirIterator1(rootPath); // Now assignment operator=() got involved. boost::filesystem::directory_iterator dirIterator2 = dirIterator1; // This line causes dirIterator1 and dirIterator2 both got incremented ... ++dirIterator1; std::cout << ""dirItertor1: "" << dirIterator1->path().string() << std::endl; std::cout << ""dirItertor2: "" << dirIterator2->path().string() << std::endl; }}} == Note == The symptom occurred in: boost::filesystem::directory_iterator[[BR]] boost::filesystem2::directory_iterator[[BR]] boost::filesystem3::directory_iterator[[BR]] boost::filesystem::recursive_directory_iterator[[BR]] boost::filesystem2::recursive_directory_iterator[[BR]] boost::filesystem3::recursive_directory_iterator[[BR]] under all platforms." Bugs new To Be Determined filesystem Boost 1.49.0 Problem directory_iterator, recursive_directory_iterator, assignment operator=()