standards/150093: C++ std::locale support is broken

Yuri Karaban tech at
Sun Aug 29 20:00:03 UTC 2010

>Number:         150093
>Category:       standards
>Synopsis:       C++ std::locale support is broken
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-standards
>State:          open
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Aug 29 20:00:02 UTC 2010
>Originator:     Yuri Karaban
>Release:        8.1-RELEASE
Standard C++ library, libstdc++, compiled with "generic" locale support. So only "C" and "POSIX" locales are supported.

Setting any other locale will throw the runtime_error exception "locale::facet::_S_create_c_locale name not valid". Though locale name is valid and works with setlocale(3).

On Linux libstdc++ is using "gnu" locale configuration. Which takes use of newlocale(3)/uselocale(3)/freelocale(3)/... POSIX calls. FreeBSD does not support these calls so it is not possible to use "gnu" configuration.

Since C++ standard allow several locale instances to coexists simultaneously, it must be not possible to implement C++ locales in terms of setlocale(3).

There are two possible solutions:

1. Implement locale related functions in FreeBSD C Library. This option is preferred: supporting standard functions is always a plus and having these function it is possible to use existing locale model in libstdc++.

2. Implement custom locale support for FreeBSD in libstdc++. Advantage that standard C library would be untouched. But on the other hand, there are many disadvantages (to create libstdc++ locale model from scratch; difficult to implement in terms of setlocale, means use of some hacks with libc internals).

PS. Locale support is really important. C++ programs which use locale is unusable on FreeBSD and there is no workaround.
Compile and run following C++ code:

#include <locale>

int main()



More information about the freebsd-standards mailing list