locale decimal point

Hi,

I am using the following lines of code to get a locale-specific decimal point however, it is causing a crash. I am unable to find any libc++ specific documentation for using std::locale but according to the STL an empty string should always be a valid locale. Does this indicate a bug in the libc++ implementation or are we doing something wrong?

std::locale my_locale("");

const std::moneypunct& mp =

std::use_facet<std::moneypunct>(my_locale);

text += mp.decimal_point();

Thanks,

Steven

When I paste that into a program, add the correct includes, declare text as a string, it works fine. (and prints ‘.’)
What version of clang are you using, what system, what C library, etc?

#include
#include
#include

int main () {
std::locale my_locale("");
const std::moneypunct& mp =
std::use_facet<std::moneypunct>(my_locale);
std::string text;
text += mp.decimal_point();
std::cout << “’” << text << “’” << std::endl;
}

– Marshall

I’m on Windows 10 and I have “#include ” at the top of my file.

@Deepak Agrawal (EDGE) What version of clang are we using?

For more info on the crash. It occurs in the function “checked_string_to_char_convert(char& dest, const char* ptr, locale_t _loc)” and the exact line is “if(*ptr == ‘\0’)”. In the debugger “ptr” is just junk. The line in our code that it crashes on is “std::locale my_locale(“”)”.

Thanks,

Steven

We are at:

CLANG_REVISION = ‘67510fac36d27b2e22c7cd955fc167136b737b93’

CLANG_SVN_REVISION = ‘361212’

CLANG_SUB_REVISION = 2

‘libcxx_revision’: ‘5938e0582bac570a41edb3d6a2217c299adc1bc6’,

‘libcxxabi_revision’: ‘0d529660e32d77d9111912d73f2c74fc5fa2a858’,

Hey Marshall,

Just following up on this.

Thanks,

Steven

Hey Marshall,

Just following up on this.

Sorry; been really busy with:

  • LLVM branch for release next week.
  • WG21 meeting next week.
  • Boost beta release next week.

That’s an auspicious commit hash (5938e0582bac570a41edb3d6a2217c299adc1bc6)

Here’s a description of the commit:
https://chromium.googlesource.com/external/llvm.org/libcxx/+/5938e0582bac570a41edb3d6a2217c299adc1bc6

Are you able to run the libc++ locale tests “locally”?
Do they pass?

– Marshall