incubator-stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Liviu Nicoara (JIRA)" <j...@apache.org>
Subject [jira] Commented: (STDCXX-402) long long stream extraction fails for strings longer than 9 decimal characters
Date Wed, 16 May 2007 16:11:16 GMT

    [ https://issues.apache.org/jira/browse/STDCXX-402?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12496339
] 

Liviu Nicoara commented on STDCXX-402:
--------------------------------------

AFAICT, the for loop at line 936 in strtoul.cpp starts by skipping the terminal zero in the
input string for strings of length 10 in base ten:

...
            // close brackets
            MULADD_4_DIGITS_END ();

            for (unsigned _RWSTD_LONG_LONG maxres =
                     _RWSTD_ULLONG_MAX / base; *++nptr; ) {

                const unsigned digit = __rw_digit_map [UChar (*nptr)];
...

HTH,
Liviu

> long long stream extraction fails for strings longer than 9 decimal characters
> ------------------------------------------------------------------------------
>
>                 Key: STDCXX-402
>                 URL: https://issues.apache.org/jira/browse/STDCXX-402
>             Project: C++ Standard Library
>          Issue Type: Bug
>          Components: 27. Input/Output
>         Environment: $ uname -a
> Linux cyberdyne 2.6.17.8 #9 SMP PREEMPT Wed Nov 22 09:34:35 EST 2006 i686 unknown unknown
GNU/Linux
> $ gcc -v
> Using built-in specs.
> Target: i486-slackware-linux
> Configured with: ../gcc-src/configure --prefix=/opt/compilers/gcc-4.1.2 --enable-shared
--enable-threads=posix --enable-__cxa_atexit --disable-checking --with-gnu-ld --verbose --target=i486-slackware-linux
--host=i486-slackware-linux --enable-languages=c,c++
> Thread model: posix
> gcc version 4.1.2
> Built a 15s version of the library.
>            Reporter: Liviu Nicoara
>
> The following test case:
> $ cat t.cpp
> #include <ios>
> #include <iostream>
> #include <sstream>
> int
> main ()
> {
>     long long n = 0;
>     {
>         std::stringstream s (std::string ("214748364"));
>         s >> n;
>         std::cout << n << "\n";
>     }
>     {
>         std::stringstream s (std::string ("2147483640"));
>         s >> n;
>         std::cout << n << "\n";
>     }
>     return 0;
> }
> Produces inconsistent (but consistently wrong) results in different runs:
> $ ./t
> 214748364
> 9223372036854775807
> $ ./t
> 214748364
> 214748365089
> $ ./t
> 214748364
> 9223372036854775807
> Liviu

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


Mime
View raw message