Issue 144829
Summary [libc++] `std::locale(named, unnamed, std::locale::none)` should obtain its name from `named`
Labels libc++
Assignees
Reporter cpplearner
    Reduced from [`libcxx/test/std/localization/locales/locale/locale.cons/name_construction.pass.cpp`](https://github.com/llvm/llvm-project/blob/351303c28e8feb85c93d8e9480f534653b032735/libcxx/test/std/localization/locales/locale/locale.cons/name_construction.pass.cpp):

```c++
#include <iostream>
#include <locale>

constexpr auto LOCALE_en_US_UTF_8 = "en_US.UTF-8";
int main(int, char**) {
    std::locale en(LOCALE_en_US_UTF_8);
    std::locale unnamed(std::locale(), new std::ctype<char>);

    {
        std::locale loc(en, unnamed, std::locale::none);
        std::cout << loc.name() << '\n';
    }
 return 0;
}
```

Both libstdc++ and MSVC's STL print "en_US.UTF-8" for `loc.name()`, but libc++ prints "*".

I think this can be fixed by swapping the two conditions in `build_name`.

https://github.com/llvm/llvm-project/blob/351303c28e8feb85c93d8e9480f534653b032735/libcxx/src/locale.cpp#L101-L110
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to