Hi Folks
I've been tracking down some almost-certainly-false-positives.
Consider the following code:
#include <iostream>
#include <boost/shared_ptr.hpp>
#include <boost/make_shared.hpp>
using namespace std;
using boost::make_shared;
struct StateSpace {
public:
StateSpace(int spaceType) {
if (spaceType == 4)
cout << "Some Output" << endl;
}
};
class State {
public:
State() : m_rep(make_shared<StateSpace>(0) ) {} // #1
// State() : m_rep(new StateSpace(0) ) {} // #2
boost::shared_ptr<StateSpace> m_rep;
};
int main() {
State state;
}
Valgrind 3.6 reports this:
==8198== Memcheck, a memory error detector
==8198== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al.
==8198== Using Valgrind-3.6.0.SVN-Debian and LibVEX; rerun with -h for
copyright info
==8198== Command: testState
==8198==
==8198== Conditional jump or move depends on uninitialised value(s)
==8198== at 0x401659: StateSpace::StateSpace(int) (testState.cpp:14)
==8198== by 0x401796: boost::shared_ptr<StateSpace>
boost::make_shared<StateSpace, int, >(int&&, ) (make_shared.hpp:150)
==8198== by 0x4016BD: State::State() (testState.cpp:22)
==8198== by 0x401317: main (testState.cpp:29)
==8198==
==8198==
==8198== HEAP SUMMARY:
==8198== in use at exit: 464 bytes in 5 blocks
==8198== total heap usage: 240 allocs, 236 frees, 45,162 bytes allocated
==8198==
==8198== LEAK SUMMARY:
==8198== definitely lost: 0 bytes in 0 blocks
==8198== indirectly lost: 0 bytes in 0 blocks
==8198== possibly lost: 0 bytes in 0 blocks
==8198== still reachable: 464 bytes in 5 blocks
==8198== suppressed: 0 bytes in 0 blocks
==8198== Reachable blocks (those to which a pointer was found) are not shown.
==8198== To see them, rerun with: --leak-check=full --show-reachable=yes
==8198==
==8198== For counts of detected and suppressed errors, rerun with: -v
==8198== Use --track-origins=yes to see where uninitialised values come from
==8198== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 5 from 5)
Interestingly, commenting out line 1 and replacing it with line 2
produces no errors.
This is, of course, a greatly boiled-down version of our actual code,
which we're very confident works correctly. Any ideas about why
Valgrind doesn't like the call to make_shared? Any ideas about how to
silence this warning (other than adding it to Valgrind's suppressions
file)?
Details:
OS: Ubuntu 10.10
Compiler: GCC 4.4.4
Valgrind: 3.6 (from the Ubuntu package)
Build command line:
/usr/local/compilers/4.4.4/bin/c++ -o dynamics/state/Test/testState.o -c -
isystem/usr/local/Boost/1.44 -isystem/usr/include/python2.6 -
isystem/home/dgsteffen/local/kml/include -ansi -Wall -Wextra -pedantic -Wno-
long-long -Wmissing-include-dirs -fshow-column -pthread -g -fdiagnostics-show-
option -std=c++0x -Woverloaded-virtual -Wno-write-strings -
DBOOST_TEST_DYN_LINK -I. dynamics/state/Test/testState.cpp
Any help is much appreciated. Thanks very much.
--
Dave Steffen, Ph.D. - Software Engineer
Numerica Corporation <http://www.numerica.us>
4850 Hahns Peak Drive, Suite 200
Loveland, Colorado 80538
main (970) 461-2000 x 227 direct (970) 612-2327
Email: [email protected]
fax (970) 461-2004
------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2 & L3.
Spend less time writing and rewriting code and more time creating great
experiences on the web. Be a part of the beta today
http://p.sf.net/sfu/msIE9-sfdev2dev
_______________________________________________
Valgrind-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/valgrind-users