Opened 10 years ago
#7535 new Bugs
filesystem::path::iterator inconsistency with multiple leading separators
Reported by: | Owned by: | Beman Dawes | |
---|---|---|---|
Milestone: | To Be Determined | Component: | filesystem |
Version: | Boost 1.51.0 | Severity: | Problem |
Keywords: | Cc: |
Description
Iterating backwards through a filesystem::path does not terminate at path::begin() if the path starts with several leading directory separators.
For example:
#include <boost/filesystem.hpp> #include <iostream> int main() { boost::filesystem::path p("/////foo"); boost::filesystem::path::iterator i = p.begin(); ++i; --i; std::cout << ((i == p.begin()) ? "same" : "different") << std::endl; }
Expected output: same
Actual output: different
Looking at the source (filesystem/src/path.cpp), it seems that in path::begin() the iterator's m_pos member is set to the position of the last leading directory separator.
During backward iteration, m_pos is set to 0, though, so the iterator comparison (which involves comparing the m_pos members) yields false.
Note:
See TracTickets
for help on using tickets.