This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/15645] New: stringstream/ostream/iomanip memory scribble bug
- From: "andrew at walrond dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 25 May 2004 07:36:10 -0000
- Subject: [Bug c++/15645] New: stringstream/ostream/iomanip memory scribble bug
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
This bug causes a segfault in my full application.This testcase does not crash,
but it does cause Valgrind to complain.
Testcase built with "gcc -lstdc++ test.cpp":
#include <sstream>
#include <iomanip>
using namespace std;
int main()
{
ostringstream oss;
oss << internal << setw(2) << 0;
}
Interestingly, the '0' triggers the behaviour. Substitute a non-zero number and
it runs without incident.
andrew@bob andrew $ valgrind --tool=memcheck a.out
==296== Memcheck, a memory error detector for x86-linux.
==296== Copyright (C) 2002-2004, and GNU GPL'd, by Julian Seward.
==296== Using valgrind-2.1.1, a program supervision framework for x86-linux.
==296== Copyright (C) 2000-2004, and GNU GPL'd, by Julian Seward.
==296== For more details, rerun with: -v
==296==
==296== Conditional jump or move depends on uninitialised value(s)
==296== 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)
==296== 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)
==296== 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)
==296== 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)
==296==
==296== Conditional jump or move depends on uninitialised value(s)
==296== 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)
==296== 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)
==296== 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)
==296== 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)
==296==
==296== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 17 from 1)
==296== malloc/free: in use at exit: 0 bytes in 0 blocks.
==296== malloc/free: 2 allocs, 2 frees, 1138 bytes allocated.
==296== For a detailed leak analysis, rerun with: --leak-check=yes
==296== For counts of detected errors, rerun with: -v
andrew@bob andrew $
--
Summary: stringstream/ostream/iomanip memory scribble bug
Product: gcc
Version: 3.3.3
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: andrew at walrond dot org
CC: gcc-bugs at gcc dot gnu dot org
GCC host triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15645