You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@stdcxx.apache.org by "Farid Zaripov (JIRA)" <ji...@apache.org> on 2007/11/02 19:15:50 UTC

[jira] Created: (STDCXX-640) std::num_get::do_get() parses no more than 128 characters

std::num_get::do_get() parses no more than 128 characters
---------------------------------------------------------

                 Key: STDCXX-640
                 URL: https://issues.apache.org/jira/browse/STDCXX-640
             Project: C++ Standard Library
          Issue Type: Bug
          Components: 22. Localization
    Affects Versions: 4.2, 4.1.4, 4.1.3, 4.1.2
         Environment: All
            Reporter: Farid Zaripov
            Priority: Minor


The following program fails on assert.

#include <cassert>
#include <sstream>
#include <string>

int main ()
{
    typedef std::num_get<char> NumGet;
    typedef std::istreambuf_iterator<char> Iter;

    std::locale loc;

    for (unsigned i = 0; i < 10000; ++i) {
        std::string s (i, '0');
        s.push_back ('1');

        std::istringstream is (s);

        std::ios::iostate state = std::ios::goodbit;
        long val = 0;

        std::use_facet<NumGet> (loc).get (Iter (is), Iter (), is, state, val);
        assert (1 == val && std::ios::eofbit == state);
    }

    return 0;
}


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (STDCXX-640) std::num_get::do_get() parses no more than 128 characters

Posted by "Farid Zaripov (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/STDCXX-640?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12539657 ] 

Farid Zaripov commented on STDCXX-640:
--------------------------------------

The reason is the fixed size buffer in num_get<_CharT, _InputIter>::_C_get(), _num_get.cc, line 253.

> std::num_get::do_get() parses no more than 128 characters
> ---------------------------------------------------------
>
>                 Key: STDCXX-640
>                 URL: https://issues.apache.org/jira/browse/STDCXX-640
>             Project: C++ Standard Library
>          Issue Type: Bug
>          Components: 22. Localization
>    Affects Versions: 4.1.2, 4.1.3, 4.1.4, 4.2
>         Environment: All
>            Reporter: Farid Zaripov
>            Priority: Minor
>
> The following program fails on assert.
> #include <cassert>
> #include <sstream>
> #include <string>
> int main ()
> {
>     typedef std::num_get<char> NumGet;
>     typedef std::istreambuf_iterator<char> Iter;
>     std::locale loc;
>     for (unsigned i = 0; i < 10000; ++i) {
>         std::string s (i, '0');
>         s.push_back ('1');
>         std::istringstream is (s);
>         std::ios::iostate state = std::ios::goodbit;
>         long val = 0;
>         std::use_facet<NumGet> (loc).get (Iter (is), Iter (), is, state, val);
>         assert (1 == val && std::ios::eofbit == state);
>     }
>     return 0;
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (STDCXX-640) std::num_get::do_get() parses no more than 128 characters

Posted by "Martin Sebor (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/STDCXX-640?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12539745 ] 

Martin Sebor commented on STDCXX-640:
-------------------------------------

In this specific case we could just skip the leading zeros but there are other cases it wouldn't work (e.g., 1<N random digits>e-<N> should parse and evaluate to 1 for any value of N).

> std::num_get::do_get() parses no more than 128 characters
> ---------------------------------------------------------
>
>                 Key: STDCXX-640
>                 URL: https://issues.apache.org/jira/browse/STDCXX-640
>             Project: C++ Standard Library
>          Issue Type: Bug
>          Components: 22. Localization
>    Affects Versions: 4.1.2, 4.1.3, 4.1.4, 4.2
>         Environment: All
>            Reporter: Farid Zaripov
>            Priority: Minor
>
> The following program fails on assert.
> #include <cassert>
> #include <sstream>
> #include <string>
> int main ()
> {
>     typedef std::num_get<char> NumGet;
>     typedef std::istreambuf_iterator<char> Iter;
>     std::locale loc;
>     for (unsigned i = 0; i < 10000; ++i) {
>         std::string s (i, '0');
>         s.push_back ('1');
>         std::istringstream is (s);
>         std::ios::iostate state = std::ios::goodbit;
>         long val = 0;
>         std::use_facet<NumGet> (loc).get (Iter (is), Iter (), is, state, val);
>         assert (1 == val && std::ios::eofbit == state);
>     }
>     return 0;
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (STDCXX-640) std::num_get::do_get() parses no more than 128 characters

Posted by "Travis Vitek (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/STDCXX-640?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12539733 ] 

Travis Vitek commented on STDCXX-640:
-------------------------------------

I don't necessarily think this is a problem with the fixed buffer size. It seems more like a problem of not skipping unnecessary zeros.

> std::num_get::do_get() parses no more than 128 characters
> ---------------------------------------------------------
>
>                 Key: STDCXX-640
>                 URL: https://issues.apache.org/jira/browse/STDCXX-640
>             Project: C++ Standard Library
>          Issue Type: Bug
>          Components: 22. Localization
>    Affects Versions: 4.1.2, 4.1.3, 4.1.4, 4.2
>         Environment: All
>            Reporter: Farid Zaripov
>            Priority: Minor
>
> The following program fails on assert.
> #include <cassert>
> #include <sstream>
> #include <string>
> int main ()
> {
>     typedef std::num_get<char> NumGet;
>     typedef std::istreambuf_iterator<char> Iter;
>     std::locale loc;
>     for (unsigned i = 0; i < 10000; ++i) {
>         std::string s (i, '0');
>         s.push_back ('1');
>         std::istringstream is (s);
>         std::ios::iostate state = std::ios::goodbit;
>         long val = 0;
>         std::use_facet<NumGet> (loc).get (Iter (is), Iter (), is, state, val);
>         assert (1 == val && std::ios::eofbit == state);
>     }
>     return 0;
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.