From mboxrd@z Thu Jan 1 00:00:00 1970 From: Peter Schmid To: gcc-gnats@gcc.gnu.org Subject: libstdc++/3720: Problems with num_get Date: Tue, 17 Jul 2001 15:06:00 -0000 Message-id: <200107172302.BAA32519@snake.iap.physik.tu-darmstadt.de> X-SW-Source: 2001-07/msg00460.html List-Id: >Number: 3720 >Category: libstdc++ >Synopsis: Problems with num_get >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Tue Jul 17 15:06:00 PDT 2001 >Closed-Date: >Last-Modified: >Originator: Peter Schmid >Release: 3.1 20010716 (experimental) >Organization: TU Darmstadt >Environment: System: Linux kiste 2.4.6 #6 Wed Jul 11 02:21:23 CEST 2001 i686 unknown Architecture: i686 SuSE 7.1 GNU ld version 2.11.90.0.23 (with BFD 2.11.90.0.23) 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=posix --enable-clocale=gnu --enable-languages=c,c++,f77,objc >Description: According to the book "The C++ Standard Library" by Josuttis on page 707 the facet num_get is used to parse the textual representation of numbers. This works, unless I enter more than 56 decimals. Somehow a segmentation fault occurs. I believe libstdc++ should handle this gracefully. >How-To-Repeat: Source code n1.C #include #include #include int main() { std::locale loc; typedef std::istreambuf_iterator ist_it; ist_it beg = ist_it(std::cin); ist_it end = ist_it(); std::ios_base& fmt = std::cin; std::ios_base::iostate err = std::ios_base::goodbit; double value; std::num_get const& ng = std::use_facet >(loc); ng.get(beg, end, fmt, err, value); std::cout << "value: " << value << std::endl; } Compiling n1.C g++ -v -o n1 n1.C -W -Wall -g 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=posix --enable-clocale=gnu --enable-languages=c,c++,f77,objc Thread model: posix gcc version 3.1 20010716 (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 -W -Wall -D_GNU_SOURCE -Acpu=i386 -Amachine=i386 -Di386 -D__i386 -D__i386__ -D__tune_i686__ -D__tune_pentiumpro__ n1.C -D__GNUG__=3 -D__DEPRECATED -D__EXCEPTIONS -D__GXX_ABI_VERSION=100 -quiet -dumpbase n1.C -g -W -Wall -version -o /tmp/ccUe5GLI.s GNU CPP version 3.1 20010716 (experimental) (cpplib) (i386 Linux/ELF) GNU C++ version 3.1 20010716 (experimental) (i686-pc-linux-gnu) compiled by GNU C version 3.1 20010716 (experimental). 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/ccp9xNWy.o /tmp/ccUe5GLI.s GNU assembler version 2.11.90.0.23 (i686-pc-linux-gnu) using BFD version 2.11.90.0.23 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1/collect2 -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 -o n1 /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/ccp9xNWy.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 Running n1 ./n1 1.2345678901234567890123456789012345678901234567890123456 Segmentation fault (core dumped) Debugging n1 GNU gdb 5.0 Copyright 2001 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "i686-pc-linux-gnu"... (gdb) r Starting program: /home/peter/trans/vergleich/mein_stlport/i18n/n1 1.2345678901234567890123456789012345678901234567890123456 Program received signal SIGSEGV, Segmentation fault. 0x0804a861 in std::num_get > >::get(std::istreambuf_iterator >, std::istreambuf_iterator >, std::ios_base&, std::_Ios_Iostate&, double&) const (this=0x0, __in= {> = {}, _M_sbuf = 0x0, _M_c = 0}, __end= {> = {}, _M_sbuf = 0x0, _M_c = 0}, __io=@0x0, __err=@0x0, __v=@0x0) at /usr/local/include/g++-v3/bits/locale_facets.h:637 (gdb) l 632 { return do_get(__in, __end, __io, __err, __v); } 633 634 iter_type 635 get(iter_type __in, iter_type __end, ios_base& __io, 636 ios_base::iostate& __err, double& __v) const 637 { return do_get(__in, __end, __io, __err, __v); } 638 639 iter_type 640 get(iter_type __in, iter_type __end, ios_base& __io, 641 ios_base::iostate& __err, long double& __v) const (gdb) bt #0 0x0804a861 in std::num_get > >::get(std::istreambuf_iterator >, std::istreambuf_iterator >, std::ios_base&, std::_Ios_Iostate&, double&) const (this=0x0, __in= {> = {}, _M_sbuf = 0x0, _M_c = 0}, __end= {> = {}, _M_sbuf = 0x0, _M_c = 0}, __io=@0x0, __err=@0x0, __v=@0x0) at /usr/local/include/g++-v3/bits/locale_facets.h:637 (gdb) >Fix: >Release-Note: >Audit-Trail: >Unformatted: