This is the mail archive of the
gcc-prs@gcc.gnu.org
mailing list for the GCC project.
libstdc++/5579: Problems with money_get
- From: Peter Schmid <schmid at snake dot iap dot physik dot tu-darmstadt dot de>
- To: gcc-gnats at gcc dot gnu dot org
- Date: Sun, 3 Feb 2002 03:37:43 +0100
- Subject: libstdc++/5579: Problems with money_get
>Number: 5579
>Category: libstdc++
>Synopsis: Problems with money_get
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sat Feb 02 17:46:00 PST 2002
>Closed-Date:
>Last-Modified:
>Originator: Peter Schmid
>Release: 3.1 20020202 (experimental)
>Organization:
TU Darmstadt
>Environment:
System: Linux kiste 2.4.17 #7 Thu Jan 3 17:21:51 CET 2002 i686 unknown
Architecture: i686
Glibc 2.2.4 + patches
Linux 2.4.17
binutils 2.11.92.0.12.3
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: ../gcc/configure --enable-shared --disable-nls --enable-threads --enable-languages=c,c++,f77,objc
>Description:
According to Table 14.15 on page 714 from the book "The C++ Standard
Library" by Josuttis when pattern is set to { symbol, none, sign,
value } $1234.54 should be legal input. But the following test case tmon
does not work. I apologize if I made a mistake.
>How-To-Repeat:
Source code tmon.C
#include <string>
#include <sstream>
#include <iostream>
class My_money_io : public std::moneypunct<char,false>
{
public:
explicit My_money_io(size_t r = 0): std::moneypunct<char,false>(r) { }
char_type do_decimal_point() const { return '.'; }
char_type do_thousand_sep() const { return ','; }
std::string do_grouping() const { return "\003\003\003"; }
std::string do_curr_symbol() const { return "$"; }
std::string do_positive_sign() const { return ""; }
std::string do_negative_sign() const { return "-"; }
int do_frac_digits() const { return 2; }
pattern do_pos_format() const
{
static pattern pat = { { symbol, none, sign, value } };
return pat;
}
pattern do_neg_format() const
{
static pattern pat = { { symbol, none, sign, value } };
return pat;
}
};
int main ()
{
using namespace std;
typedef istreambuf_iterator<char> InIt;
locale loc(locale::classic(), new My_money_io);
string buffer("$1234.56");
bool intl = false;
InIt iend;
ios_base::iostate err = ios::goodbit;
string val;
long double lval;
cerr << "good eof fail bad "
<< ios::goodbit << " "
<< ios::eofbit << " "
<< ios::failbit << " "
<< ios::badbit << endl;
const money_get<char,InIt>& mg =
use_facet<money_get<char, InIt> >(loc);
{
istringstream fmt(buffer);
InIt ibeg(fmt);
mg.get(ibeg,iend,intl,fmt,err,val);
cerr << "iostates:" << err << '\n';
}
{
istringstream fmt(buffer);
InIt ibeg(fmt);
mg.get(ibeg,iend,intl,fmt,err,lval);
cerr << "iostatel:" << err << '\n';
}
cout << "buffer:" << buffer << " val:" << val
<< " lval:" << lval << endl;
}
g++ -v -o tmon tmon.C -W -Wall
Reading specs from /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1/specs
Configured with: ../gcc/configure --enable-shared --disable-nls --enable-threads --enable-languages=c,c++,f77,objc
Thread model: posix
gcc version 3.1 20020202 (experimental)
/usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1/cc1plus -v -D__GNUC__=3 -D__GNUC_MINOR__=1 -D__GNUC_PATCHLEVEL__=0 -D__ELF__ -Dunix -Dlinux -D__ELF__ -D__unix__ -D__linux__ -D__unix -D__linux -Asystem=posix -D__NO_INLINE__ -D__STDC_HOSTED__=1 -D_GNU_SOURCE -Acpu=i386 -Amachine=i386 -Di386 -D__i386 -D__i386__ -D__tune_i686__ -D__tune_pentiumpro__ tmon.C -D__GNUG__=3 -D__DEPRECATED -D__EXCEPTIONS -D__GXX_ABI_VERSION=100 -quiet -dumpbase tmon.C -W -Wall -version -o /tmp/ccGMffsb.s
GNU CPP version 3.1 20020202 (experimental) (cpplib) (i386 Linux/ELF)
GNU C++ version 3.1 20020202 (experimental) (i686-pc-linux-gnu)
compiled by GNU C version 3.1 20020202 (experimental).
ignoring nonexistent directory "NONE/include"
ignoring nonexistent directory "/usr/local/i686-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include/g++-v3
/usr/local/include/g++-v3/i686-pc-linux-gnu
/usr/local/include/g++-v3/backward
/usr/local/include
/usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1/include
/usr/include
End of search list.
/usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1/../../../../i686-pc-linux-gnu/bin/as -V -Qy -o /tmp/ccH1OGSt.o /tmp/ccGMffsb.s
GNU assembler version 2.11.92.0.12.3 (i686-pc-linux-gnu) using BFD version 2.11.92.0.12.3 20011121
/usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1/collect2 -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 -o tmon /usr/lib/crt1.o /usr/lib/crti.o /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1/crtbegin.o -L/usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1 -L/usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1/../../../../i686-pc-linux-gnu/lib -L/usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1/../../.. /tmp/ccH1OGSt.o -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1/crtend.o /usr/lib/crtn.o
./tmon
good eof fail bad 0 2 4 1
iostates:4
iostatel:4
buffer:$1234.56 val: lval:-5.73401e-247
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted: