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

Reply via email to