libstdc++ std::locale incomplete/broken

Originator:sommerlad.peter
Number:rdar://13969869 Date Originated:23-May-2013
Status:open Resolved:
Product:libstdc++ Product Version:gcc 4.2.1
Classification:annoying Reproducible:
 
23-May-2013 10:22 AM Peter Sommerlad:
Summary:

Apple's (GNU) libstdc++ (of Apple's gcc 4.2.1) std::locale class can only be instantiated with locales "C" and "POSIX". It should be able to be instantiated with all locales installed on a system (-> locale -a output)

Steps to Reproduce:

The following program when named "loc" can be used to check which locales are supported by std::locale:
$ loc `locale -a`

--------- test program loc.cpp ----------------
#include <iostream>
#include <stdexcept>
#include <locale>

void printlocale(){
std::cout << setlocale(LC_ALL,0)<<'\n';
}

int main(int argc, char *argv[]){
printlocale();
while(*++argv) {
char const * const locstr=*argv;
setlocale(LC_ALL,locstr); // works
try {
	std::locale loc(locstr);
	std::cout << "can create locale object for : " << locstr<<'\n';
} catch (std::runtime_error &e){
	//std::cerr << "caught runtime error: " << e.what() << '\n';
}
printlocale(); // check that setlocale worked
}
}
---------------

Expected Results:

all installed locales should be supported.

Actual Results:

Only "C" and "POSIX" can be used to instantiate std::locale objects.

Regression:

Notes:

The C function setlocale seems to work with all installed locales, but not the C++ API std::locale. 
The bug is present also in gcc 4.8.0 sources when built for darwin. Linux' gcc4.8.0 builds work fine with all locales installed on a Linux system.

libc++ and clang++ allow to use all installed locales. However, all *.UTF-8 locales are broken wrt to language-specific character classification and sorting (LC_CTYPE, LC_COLLATE).

28-May-2013 09:26 PM Apple Developer Bug Reporting Team :
Engineering has determined that this is not to be fixed.

Please migrate to libc++ for the locale functionality.

Please update your bug report to let us know whether this is still an issue for you.

If you have questions regarding the resolution of this issue, please update your bug report with them.

Please be sure to regularly check new Apple products for any updates that might affect this issue.  Again, thank you for taking the time to submit bugs.  We sincerely appreciate your input.


29-May-2013 07:16 AM Peter Sommerlad:
I want to have portable code that also works with gcc and older mac os x versions, so just forcing me to use most recent library and clang is not always an option. In addition it is a pity that apple had been relying on gcc for many years and now is not fixing a minor library issue that works for libstdc++ on other platforms.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!