Opened 8 years ago

Last modified 8 years ago

#10380 new Bugs

filesystem directory iterator throws on increment

Reported by: Richard <richard.j@…> Owned by: Beman Dawes
Milestone: To Be Determined Component: filesystem
Version: Boost 1.55.0 Severity: Problem
Keywords: Cc:

Description

The following code throws an exception:

std::for_each( recursive_directory_iterator(path_to_root_dir), recursive_directory_iterator(),

[]( const directory_entry& de ) {

remove_all( de.path() );

}

);

if path_to_root_dir contains only a single sub-directory. This happens in the increment operator of the iterator at line 791 (boost/filesystem/operations.hpp: m_stack.push(directory_iterator(m_stack.top()->path()));

The sub-directory is successfully deleted. The exception is thrown after the deletion when the iterator is incremented

Change History (1)

comment:1 by Richard <richard.j@…>, 8 years ago

Forgot to mention: this happens on Windows 7/VS2010.

This also happens if there is more than one subdirectory.

If the remove_all invalidates the iterator, I would find that completely acceptable. I would, howver, expect some statements in the docs, which I could not find.

Note: See TracTickets for help on using tickets.