Opened 16 years ago
Last modified 8 years ago
#15653 assigned defect
std::locale broken in gcc
Reported by: | dirk@… | Owned by: | macports-tickets@… |
---|---|---|---|
Priority: | Normal | Milestone: | |
Component: | ports | Version: | 1.6.0 |
Keywords: | Cc: | gewesp@…, mojca (Mojca Miklavec) | |
Port: | gcc43 |
Description (last modified by ryandesign (Ryan Carsten Schmidt))
When compiling the following code:
#include <locale> #include <iostream> #include <exception> #include <clocale> void try_c_locale(const char* locale_name) { if( std::setlocale(LC_ALL, locale_name) == NULL ) printf("Failed to setlocale(LC_ALL, \"%s\")\n", locale_name); else printf("Succeeded in calling setlocale(LC_ALL, \"%s\")\n", locale_name); } void try_cpp_locale(const char* locale_name) { try { std::locale my_locale(locale_name); } catch(std::exception& e) { printf("Failed ctor for std::locale with \"%s\": %s\n", locale_name, e.what()); return; } printf("Succeeded ctor for std::locale with \"%s\"\n", locale_name); } int main(void) { // Some locales from "locale -a" on my OS X system, here is proof // that these locales do exist on my system. Take my word for it // that "locale -a" also shows these locales existing on my linux // system as well. // // rutski@imac:~$ locale -a | tail -n 2 // C // POSIX // rutski@imac:~$ locale -a | grep en_US // en_US // en_US.ISO8859-1 // en_US.ISO8859-15 // en_US.US-ASCII // en_US.UTF-8 // rutski@imac:~$ locale -a | grep pl_PL // pl_PL // pl_PL.ISO8859-2 // pl_PL.UTF-8 // rutski@imac:~$ const char* test_locales[] = { "C", "POSIX", "en_US", "en_US.UTF-8", "pl_PL", "pl_PL.ISO8859-2" }; printf("Trying c locales...\n"); for(size_t x = 0; x < sizeof(test_locales)/sizeof(char*); x++) try_c_locale(test_locales[x]); printf("\n"); printf("Trying C++ locales...\n"); for(size_t x = 0; x < sizeof(test_locales)/sizeof(char*); x++) try_cpp_locale(test_locales[x]); }
the output clearly states there is something wrong:
Trying c locales... Succeeded in calling setlocale(LC_ALL, "C") Succeeded in calling setlocale(LC_ALL, "POSIX") Succeeded in calling setlocale(LC_ALL, "en_US") Succeeded in calling setlocale(LC_ALL, "en_US.UTF-8") Succeeded in calling setlocale(LC_ALL, "pl_PL") Succeeded in calling setlocale(LC_ALL, "pl_PL.ISO8859-2") Trying C++ locales... Succeeded ctor for std::locale with "C" Succeeded ctor for std::locale with "POSIX" Failed ctor for std::locale with "en_US": locale::facet::_S_create_c_locale name not valid Failed ctor for std::locale with "en_US.UTF-8": locale::facet::_S_create_c_locale name not valid Failed ctor for std::locale with "pl_PL": locale::facet::_S_create_c_locale name not valid Failed ctor for std::locale with "pl_PL.ISO8859-2": locale::facet::_S_create_c_locale name not valid
a google serach delivers this:
http://groups.google.com/group/gnu.gcc.help/browse_thread/thread/99d874aed6b46fdd
appearantly, a --enable-clocale
to configure might do something
however, macport's configure stage does not allow for adding options (or I could not find it)
- could this be fixed in gcc? (in libstdc++)
- could this be added to macport (adding extra configure options)
Change History (11)
comment:1 Changed 16 years ago by dirk@…
Cc: | dirk@… added |
---|
comment:2 follow-up: 3 Changed 16 years ago by jmroot (Joshua Root)
Cc: | dirk@… removed |
---|---|
Milestone: | → Port Bugs |
Owner: | changed from macports-tickets@… to mww@… |
Which gcc port are you using?
comment:3 Changed 16 years ago by dirk@…
Replying to jmr@macports.org:
Which gcc port are you using?
Sorry, I forgot: gcc43
(But I think it will be so for all gcc's; apple's own xcode has it too, which is gcc 4.0)
comment:5 Changed 14 years ago by jmroot (Joshua Root)
Port: | gcc43 added |
---|
comment:6 Changed 14 years ago by ryandesign (Ryan Carsten Schmidt)
Description: | modified (diff) |
---|
comment:7 Changed 11 years ago by felipou (Felipe Machado)
This problem still applies to ports gcc48 and gcc47.
comment:8 Changed 9 years ago by gewesp@…
This still exists in 5.2.
It makes g++ unusable for any serious development.
comment:10 Changed 8 years ago by kurthindenburg (Kurt Hindenburg)
Owner: | changed from mww@… to macports-tickets@… |
---|---|
Status: | new → assigned |
comment:11 Changed 8 years ago by mojca (Mojca Miklavec)
Cc: | mojca added |
---|
Cc Me!