This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Suspicious C++ stringstream crashes, gcc 3.3.3
On Tuesday 25 May 2004 00:05, Phil Edwards wrote:
>
> No, but a complete bug report might.
>
> http://gcc.gnu.org/bugs.html
>
> Specifically, a reproducible test case.
Ok, I've isolated the problem, and it is indeed where I thought it to be.
I must stress that the testcase below doesn't segfault, but it causes valgrind
to spit out the same error as previously reported.
Interestingly, its the '0' that triggers the behaviour. Substitute '1', and it
runs through valgrind without incident.
This gcc 3.3.3 on x86 linux. Testcase built with "gcc -lstdc++ test.cpp"
#include <sstream>
#include <iomanip>
using namespace std;
int main()
{
ostringstream oss;
oss << internal << setw(2) << 0;
}
andrew@bob andrew $ valgrind --tool=memcheck ./a.out
==8915== Memcheck, a memory error detector for x86-linux.
==8915== Copyright (C) 2002-2004, and GNU GPL'd, by Julian Seward.
==8915== Using valgrind-2.1.1, a program supervision framework for x86-linux.
==8915== Copyright (C) 2000-2004, and GNU GPL'd, by Julian Seward.
==8915== For more details, rerun with: -v
==8915==
==8915== Conditional jump or move depends on uninitialised value(s)
==8915== at 0x3C07D9A6: std::__pad<char, std::char_traits<char>
>::_S_pad(std::ios_base&, char, char*, char const*, int, int, bool)
(in /pkg/gcc.2/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/libstdc++.so.5.0.5)
==8915== by 0x3C07DA83: std::num_put<char, std::ostreambuf_iterator<char,
std::char_traits<char> > >::_M_pad(char, int, std::ios_base&, char*, char
const*, int&) const
(in /pkg/gcc.2/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/libstdc++.so.5.0.5)
==8915== by 0x3C07E94A: std::ostreambuf_iterator<char,
std::char_traits<char> > std::num_put<char, std::ostreambuf_iterator<char,
std::char_traits<char> >
>::_M_convert_int<long>(std::ostreambuf_iterator<char, std::char_traits<char>
>, std::ios_base&, char, long) const
(in /pkg/gcc.2/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/libstdc++.so.5.0.5)
==8915== by 0x3C07E4CF: std::num_put<char, std::ostreambuf_iterator<char,
std::char_traits<char> > >::do_put(std::ostreambuf_iterator<char,
std::char_traits<char> >, std::ios_base&, char, long) const
(in /pkg/gcc.2/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/libstdc++.so.5.0.5)
==8915==
==8915== Conditional jump or move depends on uninitialised value(s)
==8915== at 0x3C07D9DD: std::__pad<char, std::char_traits<char>
>::_S_pad(std::ios_base&, char, char*, char const*, int, int, bool)
(in /pkg/gcc.2/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/libstdc++.so.5.0.5)
==8915== by 0x3C07DA83: std::num_put<char, std::ostreambuf_iterator<char,
std::char_traits<char> > >::_M_pad(char, int, std::ios_base&, char*, char
const*, int&) const
(in /pkg/gcc.2/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/libstdc++.so.5.0.5)
==8915== by 0x3C07E94A: std::ostreambuf_iterator<char,
std::char_traits<char> > std::num_put<char, std::ostreambuf_iterator<char,
std::char_traits<char> >
>::_M_convert_int<long>(std::ostreambuf_iterator<char, std::char_traits<char>
>, std::ios_base&, char, long) const
(in /pkg/gcc.2/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/libstdc++.so.5.0.5)
==8915== by 0x3C07E4CF: std::num_put<char, std::ostreambuf_iterator<char,
std::char_traits<char> > >::do_put(std::ostreambuf_iterator<char,
std::char_traits<char> >, std::ios_base&, char, long) const
(in /pkg/gcc.2/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/libstdc++.so.5.0.5)
==8915==
==8915== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 17 from 1)
==8915== malloc/free: in use at exit: 0 bytes in 0 blocks.
==8915== malloc/free: 2 allocs, 2 frees, 1138 bytes allocated.
==8915== For a detailed leak analysis, rerun with: --leak-check=yes
==8915== For counts of detected errors, rerun with: -v