Description
[locale.facet]/5 suggests that a locale constructed with constructor locale(const char*)
should provide facets of type [facet]_byname
, but MSVC STL constructs facets of type [facet]
instead.
Test case
#include <iostream>
#include <locale>
using namespace std;
int main() {
locale loc("en_US");
const auto& coll = use_facet<collate<char>>(loc);
cout << typeid(coll).name();
}
https://godbolt.org/z/a556r5czc
Expected behavior
This should print class std::collate_byname<char>
, but actually prints class std::collate<char>
.
Additional context
This bug means that we can't implement the resolution of LWG-4186 (#5291) as-is.
[locale.category]/3 seems to suggest that [facet]
and not [facet]_byname
is the correct type for the C locale returned by locale::classic()
. But this creates some tension in the spec: [locale.facet]/5 suggests that locale(const char*)
should construct [facet]_byname
facets, while [locale.statics]/5 says that locale::classic()
should return a locale equivalent to locale("C")
. Are the locales still considered equivalent if the facet types aren't the same?
Note that libc++ solves this by producing C locales with different facet types for locale("C")
and locale::classic()
: https://godbolt.org/z/nzW4qxja1