[libcxx-dev] locale decimal point
Steven Lengieza via libcxx-dev
libcxx-dev at lists.llvm.org
Fri Jun 28 09:23:11 PDT 2019
I’m on Windows 10 and I have “#include <locale>” at the top of my file.
@Deepak Agrawal (EDGE)<mailto:deepakag at microsoft.com> 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
From: Marshall Clow <mclow.lists at gmail.com>
Sent: Friday, June 28, 2019 7:51 AM
To: Steven Lengieza <Steven.Lengieza at microsoft.com>
Cc: libcxx-dev at lists.llvm.org; Deepak Agrawal (EDGE) <deepakag at microsoft.com>
Subject: Re: [libcxx-dev] locale decimal point
On Fri, Jun 28, 2019 at 7:45 AM Steven Lengieza via libcxx-dev <libcxx-dev at lists.llvm.org<mailto:libcxx-dev at lists.llvm.org>> wrote:
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<char>& mp =
std::use_facet<std::moneypunct<char>>(my_locale);
text += mp.decimal_point();
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 <locale>
#include <iostream>
#include <string>
int main () {
std::locale my_locale("");
const std::moneypunct<char>& mp =
std::use_facet<std::moneypunct<char>>(my_locale);
std::string text;
text += mp.decimal_point();
std::cout << "'" << text << "'" << std::endl;
}
-- Marshall
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/libcxx-dev/attachments/20190628/e6e9253f/attachment-0001.html>
More information about the libcxx-dev
mailing list