I have the following error when using valgrind:
==3099== Conditional jump or move depends on uninitialised value(s)
==3099== at 0x40BA65D: std::ostreambuf_iterator<char, std::char_traits<char> > std::num_put<char, std::ostreambuf_iterator<char, std::char_traits<char> > >::_M_insert_int<long>(std::ostreambuf_iterator<char, std::char_traits<char> >, std::ios_base&, char, long) const (in /usr/lib/libstdc++.so.6.0.14)
==3099== by 0x40BA98C: 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 /usr/lib/libstdc++.so.6.0.14)
==3099== by 0x40C5A98: std::ostream& std::ostream::_M_insert<long>(long) (in /usr/lib/libstdc++.so.6.0.14)
==3099== by 0x40C5C13: std::ostream::operator<<(int) (in /usr/lib/libstdc++.so.6.0.14)
==3099== by 0x80A5CC6: Ser::method() (in /home/user)
==3099== by 0x80BCA61: bool Ser() (in /home/user)
==3099== by 0x80958D1: Ser::Select() (in /home/user)
==3099== by 0x804B85D: main (in /home/user)
==3099==
==3099== Use of uninitialised value of size 4
==3099== at 0x40BA12E: ??? (in /usr/lib/libstdc++.so.6.0.14)
==3099== by 0x40BA693: std::ostreambuf_iterator<char, std::char_traits<char> > std::num_put<char, std::ostreambuf_iterator<char, std::char_traits<char> > >::_M_insert_int<long>(std::ostreambuf_iterator<char, std::char_traits<char> >, std::ios_base&, char, long) const (in /usr/lib/libstdc++.so.6.0.14)
==3099== by 0x40BA98C: 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 /usr/lib/libstdc++.so.6.0.14)
==3099== by 0x40C5A98: std::ostream& std::ostream::_M_insert<long>(long) (in /usr/lib/libstdc++.so.6.0.14)
==3099== by 0x40C5C13: std::ostream::operator<<(int) (in /usr/lib/libstdc++.so.6.0.14)
==3099==开发者_JAVA技巧 by 0x80A5CC6: Ser::method() (in /home/user)
==3099== by 0x80BCA61: bool Ser::Call() (in /home//user)
==3099== by 0x80958D1: Ser::Select() (in /home/user)
==3099== by 0x804B85D: main (in /home/user)
What does this mean? Where is the error?
This error means that you are working with some variables before they were initialized. Looks like you are printing uninitialized int
value in Ser::method()
. You should initialize it before printing.
精彩评论