This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
libstdc++/5110: num_put caches num_punct values
- From: sebor at roguewave dot com
- To: gcc-gnats at gcc dot gnu dot org
- Date: 14 Dec 2001 02:50:24 -0000
- Subject: libstdc++/5110: num_put caches num_punct values
- Reply-to: sebor at roguewave dot com
>Number: 5110
>Category: libstdc++
>Synopsis: num_put caches num_punct values
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu Dec 13 18:56:00 PST 2001
>Closed-Date:
>Last-Modified:
>Originator: sebor@roguewave.com
>Release: gcc 3.0.1
>Organization:
>Environment:
>Description:
The program below produces unexpected output and fails
with non-0 exit status. The expected output is
123+456+78+9-1-234-567-89-123/456/789
and the expected exit status is 0. My guess is that it's
because num_put is caching the values supplied by numpunct,
which I don't believe is permitted in Stage 2 in 22.2.2.2.2.
Regards
Martin
>How-To-Repeat:
$ cat t.cpp
#include <iostream>
#include <locale>
int main ()
{
struct Punct: std::numpunct<char> {
string_type do_grouping () const {
static const char *grp = "\1\2\3";
return grp++;
}
char_type do_thousands_sep () const {
static const char *sep = "+-/";
return *sep++;
}
};
std::locale l (std::cout.getloc (), (std::numpunct<char>*)new Punct);
std::cout.imbue (l);
std::cout << 123456789 << -123456789 << -123456789 << std::endl;
return *std::use_facet<std::numpunct<char> >(std::cout.getloc ()).grouping (
).c_str ();
}
$ g++ t.cpp
$ ./a.out ; echo $?
123+456+78+9-123+456+78+9-123+456+78+9
2
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted: