public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/22131] New: std::num_get fails for input with invalid groups
@ 2005-06-20 23:48 sebor at roguewave dot com
  2005-06-24  8:52 ` [Bug libstdc++/22131] " chris at bubblescope dot net
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: sebor at roguewave dot com @ 2005-06-20 23:48 UTC (permalink / raw)
  To: gcc-bugs

The program below is expected to run successfully to completion but when
compiled with gcc 3.4.3 or 4.0.0 it aborts.

$ cat u.cpp && g++ u.cpp && ./a.out
#include <locale>
#include <sstream>
#include <cassert>

int main ()
{
    struct Punct: std::numpunct<char> {
        std::string do_grouping () const { return "\1"; }
        char do_thousands_sep () const { return '#'; }
    };

    std::istringstream strm ("00#0#1");
    strm.imbue (std::locale (strm.getloc (), (std::numpunct<char>*)new Punct));

    int x = 0;
    strm >> x;

    assert (1 == x);
    assert ((strm.eofbit | strm.failbit) == strm.rdstate ());
}
Assertion failed: 1 == x, file u.cpp, line 18
Abort (core dumped)

-- 
           Summary: std::num_get fails for input with invalid groups
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: libstdc++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: sebor at roguewave dot com
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22131


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libstdc++/22131] std::num_get fails for input with invalid groups
  2005-06-20 23:48 [Bug libstdc++/22131] New: std::num_get fails for input with invalid groups sebor at roguewave dot com
@ 2005-06-24  8:52 ` chris at bubblescope dot net
  2005-06-24 12:18 ` pcarlini at suse dot de
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: chris at bubblescope dot net @ 2005-06-24  8:52 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From chris at bubblescope dot net  2005-06-24 08:52 -------
It's probably me being blind, but could you point out the part of the standard
which defines what should be happening?

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22131


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libstdc++/22131] std::num_get fails for input with invalid groups
  2005-06-20 23:48 [Bug libstdc++/22131] New: std::num_get fails for input with invalid groups sebor at roguewave dot com
  2005-06-24  8:52 ` [Bug libstdc++/22131] " chris at bubblescope dot net
@ 2005-06-24 12:18 ` pcarlini at suse dot de
  2005-06-24 17:11 ` sebor at roguewave dot com
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pcarlini at suse dot de @ 2005-06-24 12:18 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pcarlini at suse dot de  2005-06-24 12:18 -------
If I understand correctly Martin, the point is that, according to 
22.2.2.1.2/11-12, even when the groups are invalid (indeed, he expects a fail
in the second assert) the value is stored in val anyway. If this is his point,
I believe he is right, we have a bug, certainly not terribly difficult to fix ;)

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22131


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libstdc++/22131] std::num_get fails for input with invalid groups
  2005-06-20 23:48 [Bug libstdc++/22131] New: std::num_get fails for input with invalid groups sebor at roguewave dot com
  2005-06-24  8:52 ` [Bug libstdc++/22131] " chris at bubblescope dot net
  2005-06-24 12:18 ` pcarlini at suse dot de
@ 2005-06-24 17:11 ` sebor at roguewave dot com
  2005-06-24 18:22 ` pcarlini at suse dot de
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: sebor at roguewave dot com @ 2005-06-24 17:11 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From sebor at roguewave dot com  2005-06-24 17:11 -------
Yes, sorry for being too terse. The value is supposed to be stored even if the
placement of the thousands separators is invalid, just as long as the input
sequence matches the grammar in 22.2.3.1, p2.

For example, while "00#0#1" matches the grammar, "000##1" doesn't (because
consecutive thousands sperataors are not permitted). In neither case does the
placement of the thousands separators match the grouping, so failbit is set. But
in the former cases the facet is supposed to store the value while in the latter
it must leave it unchanged.

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22131


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libstdc++/22131] std::num_get fails for input with invalid groups
  2005-06-20 23:48 [Bug libstdc++/22131] New: std::num_get fails for input with invalid groups sebor at roguewave dot com
                   ` (2 preceding siblings ...)
  2005-06-24 17:11 ` sebor at roguewave dot com
@ 2005-06-24 18:22 ` pcarlini at suse dot de
  2005-06-29 11:49 ` cvs-commit at gcc dot gnu dot org
  2005-06-29 12:08 ` pcarlini at suse dot de
  5 siblings, 0 replies; 7+ messages in thread
From: pcarlini at suse dot de @ 2005-06-24 18:22 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pcarlini at suse dot de  2005-06-24 18:22 -------
Thanks Martin for the clarification: 100% agreed, also about the grammar thing.
I will fix that in a few days, as soon as I'm back from GCCSummit.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |pcarlini at suse dot de
                   |dot org                     |
             Status|UNCONFIRMED                 |ASSIGNED
     Ever Confirmed|                            |1
   Last reconfirmed|0000-00-00 00:00:00         |2005-06-24 18:22:04
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22131


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libstdc++/22131] std::num_get fails for input with invalid groups
  2005-06-20 23:48 [Bug libstdc++/22131] New: std::num_get fails for input with invalid groups sebor at roguewave dot com
                   ` (3 preceding siblings ...)
  2005-06-24 18:22 ` pcarlini at suse dot de
@ 2005-06-29 11:49 ` cvs-commit at gcc dot gnu dot org
  2005-06-29 12:08 ` pcarlini at suse dot de
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2005-06-29 11:49 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2005-06-29 11:49 -------
Subject: Bug 22131

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	paolo@gcc.gnu.org	2005-06-29 11:48:54

Modified files:
	libstdc++-v3   : ChangeLog 
	libstdc++-v3/include/bits: locale_facets.tcc 
	libstdc++-v3/config/locale/generic: c_locale.cc 
	libstdc++-v3/config/locale/gnu: c_locale.cc 
	libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char: 
	                                                                       07.cc 
	libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t: 
	                                                                          07.cc 
	libstdc++-v3/testsuite/22_locale/num_get/get/char: 12.cc 
	libstdc++-v3/testsuite/22_locale/num_get/get/wchar_t: 12.cc 
Added files:
	libstdc++-v3/testsuite/22_locale/money_get/get/char: 22131.cc 
	libstdc++-v3/testsuite/22_locale/money_get/get/wchar_t: 22131.cc 
	libstdc++-v3/testsuite/22_locale/num_get/get/char: 22131.cc 
	libstdc++-v3/testsuite/22_locale/num_get/get/wchar_t: 22131.cc 

Log message:
	2005-06-29  Paolo Carlini  <pcarlini@suse.de>
	
	PR libstdc++/22131
	* include/bits/locale_facets.tcc (num_get<>::_M_extract_int,
	num_get<>::_M_extract_float, money_get<>::_M_extract):
	Adjust to assign the result also when digit grouping is
	wrong (but the grammar is correct), as per 22.2.2.1.2, p11-12
	(NB: consistently for money_get too).
	* config/locale/generic/c_locale.cc (__convert_from_v): Do
	not check ios_base::failbit at the outset.
	* config/locale/gnu/c_locale.cc: Likewise.
	* testsuite/22_locale/money_get/get/char/22131.cc: New.
	* testsuite/22_locale/money_get/get/wchar_t/22131.cc: Likewise.
	* testsuite/22_locale/num_get/get/char/22131.cc: Likewise.
	* testsuite/22_locale/num_get/get/wchar_t/22131.cc: Likewise.
	* testsuite/22_locale/num_get/get/char/12.cc: Adjust.
	* testsuite/22_locale/num_get/get/wchar_t/12.cc: Likewise.
	* testsuite/27_io/basic_istream/extractors_arithmetic/char/07.cc:
	Likewise.
	* testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/07.cc:
	Likewise.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/ChangeLog.diff?cvsroot=gcc&r1=1.3047&r2=1.3048
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/bits/locale_facets.tcc.diff?cvsroot=gcc&r1=1.215&r2=1.216
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/config/locale/generic/c_locale.cc.diff?cvsroot=gcc&r1=1.19&r2=1.20
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/config/locale/gnu/c_locale.cc.diff?cvsroot=gcc&r1=1.16&r2=1.17
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/07.cc.diff?cvsroot=gcc&r1=1.5&r2=1.6
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/07.cc.diff?cvsroot=gcc&r1=1.1&r2=1.2
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/22_locale/money_get/get/char/22131.cc.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/22_locale/money_get/get/wchar_t/22131.cc.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/22_locale/num_get/get/char/22131.cc.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/22_locale/num_get/get/char/12.cc.diff?cvsroot=gcc&r1=1.2&r2=1.3
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/22_locale/num_get/get/wchar_t/22131.cc.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/22_locale/num_get/get/wchar_t/12.cc.diff?cvsroot=gcc&r1=1.2&r2=1.3



-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22131


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libstdc++/22131] std::num_get fails for input with invalid groups
  2005-06-20 23:48 [Bug libstdc++/22131] New: std::num_get fails for input with invalid groups sebor at roguewave dot com
                   ` (4 preceding siblings ...)
  2005-06-29 11:49 ` cvs-commit at gcc dot gnu dot org
@ 2005-06-29 12:08 ` pcarlini at suse dot de
  5 siblings, 0 replies; 7+ messages in thread
From: pcarlini at suse dot de @ 2005-06-29 12:08 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pcarlini at suse dot de  2005-06-29 12:08 -------
Fixed for 4.1.0.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.1.0


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22131


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2005-06-29 12:08 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-06-20 23:48 [Bug libstdc++/22131] New: std::num_get fails for input with invalid groups sebor at roguewave dot com
2005-06-24  8:52 ` [Bug libstdc++/22131] " chris at bubblescope dot net
2005-06-24 12:18 ` pcarlini at suse dot de
2005-06-24 17:11 ` sebor at roguewave dot com
2005-06-24 18:22 ` pcarlini at suse dot de
2005-06-29 11:49 ` cvs-commit at gcc dot gnu dot org
2005-06-29 12:08 ` pcarlini at suse dot de

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).