main/libstdc++: std::locale("") throws invalid locale
quick reproduction:
#include <locale>
int main() {
std::locale("");
}
(you need to have any non-C locale. LC_ALL=C is the only way to make that not throw- LC_ALL=C.UTF-8 does)
this is quite an old issue- it's been known for an extremely long time here and there, and is caused by a shortcoming in the posix/generic libstdc++ locale backend.
the specific issue comes from here:
// Currently, the generic model only supports the "C" locale.
// See http://gcc.gnu.org/ml/libstdc++/2003-02/msg00345.html
__cloc = 0;
if (strcmp(__s, "C"))
__throw_runtime_error(__N("locale::facet::_S_create_c_locale "
"name not valid"));
however, merely patching this check out, with a patch carried by both void and adélie, makes that not throw. and then the application does work, and that code does what it's intended to (set locale to user LC/LANG locale with std::locale::global(std::locale(""));
or similar, as the default is C), and the actual localisation/translations work.
the only issue is that, some strings do actually segfault when passed to std::locale (only with the above patch)- notably:
std::locale(setlocale(/* basically anything */));
the reason why is setlocale returns things that are ;
delimited, and that causes something in that std::locale backend to segfault. however, i don't believe this is actually allowed by the standard? i'm not sure, but..
in any case, my proposal is to add the above patch, as without it localisations cannot work in some programs- in testing/easyeffects for instance i had to patch out every ("") to () to fix them, as otherwise it can only be launched with LC_ALL=C. and if these other distros carry it too, then i assume it's been tested in practice well enough that probably no random program is going to crash.
if someone knows how to efficiently grep through a ton of code in debian codesearch or something for that specific instance preemptively that would be nice, but it's fine to patch regardless imo
the real solution would be fixing this in libstdc++, but i have no actual knowledge of how to do so.