incubator-stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Martin Sebor (JIRA)" <j...@apache.org>
Subject [jira] Commented: (STDCXX-402) long long stream extraction fails for strings longer than 9 decimal characters
Date Mon, 07 May 2007 17:30:15 GMT

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

Martin Sebor commented on STDCXX-402:
-------------------------------------

Something very bizarre is going on here. I was able to reliably reproduce slightly different
but equally incorrect behavior on trunk (you didn't say which version you used) in an 11s
build with gcc 4.1.0 on Solaris 9 with the simplified test case below. What's bizarre about
it is that when I step through (but not run) the same program in gdb 6.5 I get the expected
output. Replacing the string temporary with just the string literal lets the program behave
correctly suggesting some kind of weird memory corruption.

Current directory is /build/sebor/stdcxx-gcc-4.1.0-11s/examples/
GNU gdb 6.5
Copyright (C) 2006 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 "sparc-sun-solaris2.9"...
(gdb) l
1	#include <cstdio>
2	#include <sstream>
3	
4	int main () {
5	    std::stringstream s (std::string ("2147483640"));
6	    long long n = 0;
7	    s >> n;
8	    std::printf ("%llu\n", n);
9	}
(gdb) r
Starting program: /build/sebor/stdcxx-gcc-4.1.0-11s/examples/u 
9223372036854775807

Program exited normally.
(gdb) b main
Breakpoint 1 at 0x11c20: file u.cpp, line 5.
(gdb) r
Starting program: /build/sebor/stdcxx-gcc-4.1.0-11s/examples/u 

Breakpoint 1, main () at u.cpp:5
(gdb) n
(gdb) n
(gdb) n
(gdb) n
2147483640
(gdb) c
Continuing.

Program exited normally.
(gdb) 

> 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