Subject: [Boost-bugs] [Boost C++ Libraries] #4846: streaming gregorian::date objects to std::cout leaks memory
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2010-11-12 13:07:30
#4846: streaming gregorian::date objects to std::cout leaks memory
---------------------------------+------------------------------------------
Reporter: robbie@⦠| Owner: az_sw_dude
Type: Bugs | Status: new
Milestone: To Be Determined | Component: date_time
Version: Boost 1.44.0 | Severity: Problem
Keywords: |
---------------------------------+------------------------------------------
there seems to be a problem streaming boost::gregorian::date objects to
std::cout, but not to std::ostringstream / whilst noting that this could
be a valgrind issue
consider the following code
{{{
// build : $ g++ -ggdb -Wall -pedantic -Weffc++ test.cc -o test
// run : $ valgrind ./test
// compiler : g++ (Ubuntu 4.4.3-4ubuntu5) 4.4.3
// library : Boost 1.44.0
#include <iostream> // standard io
#include <sstream> // string-streams
#include <boost/date_time/gregorian/gregorian.hpp>
int
main()
{
namespace bg = boost::gregorian; // namespace alias
const bg::date today(2010, bg::Nov, 12); // 'const' not
significant
std::ostringstream oss;
oss << today;
std::cout << "today (1) : " << oss.str() << std::endl; // okay
std::cout << "today (2) : " << today << std::endl; // faulty
}
}}}
valgrind output
{{{
==15924== Memcheck, a memory error detector
==15924== Copyright (C) 2002-2009, and GNU GPL'd, by Julian Seward et al.
==15924== Using Valgrind-3.6.0.SVN-Debian and LibVEX; rerun with -h for
copyright info
==15924== Command: ./test
==15924==
today (1) : 2010-Nov-12
today (2) : 2010-Nov-12
==15924==
==15924== HEAP SUMMARY:
==15924== in use at exit: 1,544 bytes in 26 blocks
==15924== total heap usage: 64 allocs, 38 frees, 4,609 bytes allocated
==15924==
==15924== LEAK SUMMARY:
==15924== definitely lost: 0 bytes in 0 blocks
==15924== indirectly lost: 0 bytes in 0 blocks
==15924== possibly lost: 568 bytes in 19 blocks
==15924== still reachable: 976 bytes in 7 blocks
==15924== suppressed: 0 bytes in 0 blocks
==15924== Rerun with --leak-check=full to see details of leaked memory
==15924==
==15924== For counts of detected and suppressed errors, rerun with: -v
==15924== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 4 from 4)
}}}
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/4846> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:04 UTC