This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Problem with the fr_FR locale and libstdc++ with GCC 4.3.2
- From: "David Ritter" <David dot Ritter at roguewave dot com>
- To: <gcc-help at gcc dot gnu dot org>
- Date: Tue, 3 Nov 2009 13:51:59 -0700
- Subject: Problem with the fr_FR locale and libstdc++ with GCC 4.3.2
Hello,
I am seeing what I believe is a bug with GCC 4.3.2 and libstdc++ and I
wanted to know if anyone else has seen it.
With the following code, if I run it on GCC 4.3.2 there is no weekday
number returned by the time_get() call. However if I run the same code
on GCC 3.4.6 or GCC 4.1.2 it runs correctly.
Is this a known issue?
/********* Test case *******/
#include <sstream>
#include <locale>
#include <iostream>
#include <assert.h>
int main()
{
const char* name = "fr_FR";
const char* fmt = "%A";
std::string str;
struct tm t = tm();
std::locale loc (name);
t.tm_wday = 2;
{
typedef std::ostreambuf_iterator<char> iter_t;
std::ostringstream os;
os.imbue (loc);
iter_t os_iter(os.rdbuf ());
const char* fmt_end = fmt + std::char_traits<char>::length(fmt);
const std::time_put<char,iter_t>& fac =
std::use_facet<std::time_put<char,iter_t> >(loc);
fac.put(os_iter, os, os.fill(), &t, fmt, fmt_end);
str = os.str();
std::cout << "From the ostream" << std::endl
<< str << std::endl;
}
t.tm_wday = 0;
{
typedef std::istreambuf_iterator<char> iter_t;
std::istringstream is(str);
iter_t start(is);
iter_t end;
is.imbue(loc);
const std::time_get<char,iter_t>& fac =
std::use_facet<std::time_get<char,iter_t> >(loc);
std::ios_base::iostate err (std::ios_base::goodbit);
fac.get_weekday(start, end, is, err, &t);
if (err == std::ios_base::failbit || err == std::ios_base::badbit)
{
fprintf(stdout, "error\n");
}
fprintf(stdout, "Reflected number is %d\n", t.tm_wday);
}
return 0;
}
/****** End Test ******/
// expected output (from GCC 3.4.6 & GCC 4.1.2)
From the ostream
mardi
Reflected number is 2
// Error output from (GCC 4.3.2)
From the ostream
mardi
error
Reflected number is 0
Thanks you for any help,
Dave Ritter
----------------------------------------
David Ritter
Rogue Wave Software
Software Developer
----------------------------------------
----------------------------------------
David Ritter
Rogue Wave Software
Software Developer
----------------------------------------