Reputation: 2499
Not clear what is going on: I have the 2 following lines that works in other parts of the code:
map<short,string> params;
params.insert( std::pair<short, string>(5, string("ee")) );
when I put it into my routine, I get this valgring error right at the beginning, and the program crashes. Not totally clear why it ends up in the string destructor. I may have something wrong with my binary but I am a little confused why it happens right at the beginning and why is it in the string destructor ? Does what is herebelow MEANS that I must look for the error somewhere else ?
==2052== Conditional jump or move depends on uninitialised value(s)
==2052== at 0x6073EC2: std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string() (in /usr/lib/libstdc++.so.6.0.13)
==2052== by 0x42428B: std::pair<short const, std::string>::~pair() (stl_pair.h:68)
==2052== by 0x4B99FB: NLGSearch::Search::Calc() (Search.cpp:409)
Note that it goes through if I use map<short,short>
Thank you.
--------------------------------------------------- EDIT
This is used right at the beginning of a method. I guess I have the answer to my question, I have to look at somewhere else in my code...
lef@dxml:~$ more /etc/issue
Debian GNU/Linux 6.0 \n \l
lef@dxml:~$ g++ -v
Using built-in specs.
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 4.4.5-8' --with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.4 --enable-shared --enable-multiarch --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.4 --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --with-arch-32=i586 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.4.5 (Debian 4.4.5-8)
Upvotes: 1
Views: 509
Reputation: 168616
It works for me. How does this program differ from the one you are testing?
#include <map>
#include <string>
int main () {
using std::map;
using std::string;
map<short,string> params;
params.insert( std::pair<short, string>(5, string("ee")) );
}
gcc 4.4.3 on Ubuntu 10.04.3 LTS. No complaints from valgrind.
Upvotes: 1