Opened 8 years ago

Closed 8 years ago

#10641 closed Bugs (fixed)

boost::filesystem::path::parent_path() throws run time error locale::facet::_S_create_c_locale name not valid

Reported by: maxiaoyin@… Owned by: Beman Dawes
Milestone: Boost 1.57.0 Component: filesystem
Version: Boost 1.56.0 Severity: Problem
Keywords: filesystem Cc:

Description

I have the following code under ubuntu 12.04 with gcc 4.3.6 .

#include <iostream>
#include <boost/filesystem/path.hpp>
using namespace std;
namespace fs = boost::filesystem
int main(int argc, char** argv)
{

	try
	{
		fs::path my_path("test/test.txt");
		cout << "current path is      " << my_path << endl;
		cout << "parent path is       " << my_path.parent_path() << endl;
	}
	catch(std::exception& e) {
		cerr << endl << "Error during execution: " << e.what() << endl << endl;
		return EXIT_FAILURE;
	}
	return EXIT_SUCCESS;
}

I was able to create a path using the string "test/test.txt" and print out the path as a string. However, when I was trying to access the parent_path() or stem() or extension() the program will fail and throw locale::facet::_S_create_c_locale name not valid error.

output: current path is "test/test.txt"

Error during execution: locale::facet::_S_create_c_locale name not valid

Change History (2)

comment:1 by anonymous, 8 years ago

I noticed that if I use filesystem version 2.0 in boost 1.49, there is no such issue.

comment:2 by Beman Dawes, 8 years ago

Milestone: To Be DeterminedBoost 1.57.0
Resolution: fixed
Status: newclosed

Your test program failed as expected, although only if the LANG environmental variable was set to an invalid value.

It was tested again, after applying the fix, and ran correctly.

The fix has been pushed to develop, and so should be in time for the 1.57.0 release. The effect of the changes just pushed is to roll out the earlier specific fixes for a few path signatures to the general case of all path functions that perform conversions using path::codecvt() to supply the default codecvt facet.

Thanks for the report,

--Beman

Note: See TracTickets for help on using tickets.