I'm trying to use Valgrind on Raspberry Pi. I am analyzing the following program:
#include <string>
#include <cstring>
int main() {
std::string blaat = "blaat";
const char * buf = blaat.c_str();
size_t l = 0;
l = strlen(buf);
printf("string size %u\n", l);
}
Compile:
g++ -g -Wall -O0 test.cpp
Analyze (valgrind-3.16.1):
valgrind --leak-check=yes ./a.out
Result:
==29572==
==29572== Conditional jump or move depends on uninitialised value(s)
==29572== at 0x4866210: ??? (in /usr/lib/arm-linux-gnueabihf/libarmmem-v7l.so)
==29572==
==29572== Conditional jump or move depends on uninitialised value(s)
==29572== at 0x48662DC: ??? (in /usr/lib/arm-linux-gnueabihf/libarmmem-v7l.so)
==29572==
==29572== Use of uninitialised value of size 4
==29572== at 0x4AABF6C: _itoa_word (_itoa.c:179)
==29572== by 0x4AB0727: vfprintf (vfprintf.c:1637)
==29572== by 0x4AB646F: printf (printf.c:33)
==29572== by 0x1088F: main (test.c:10)
==29572==
==29572== Conditional jump or move depends on uninitialised value(s)
==29572== at 0x4AABF74: _itoa_word (_itoa.c:179)
==29572== by 0x4AB0727: vfprintf (vfprintf.c:1637)
==29572== by 0x4AB646F: printf (printf.c:33)
==29572== by 0x1088F: main (test.c:10)
==29572==
==29572== Conditional jump or move depends on uninitialised value(s)
==29572== at 0x4AAF8FC: vfprintf (vfprintf.c:1637)
==29572== by 0x4AB646F: printf (printf.c:33)
==29572== by 0x1088F: main (test.c:10)
==29572==
==29572== Conditional jump or move depends on uninitialised value(s)
==29572== at 0x4AAF99C: vfprintf (vfprintf.c:1637)
==29572== by 0x4AB646F: printf (printf.c:33)
==29572== by 0x1088F: main (test.c:10)
==29572==
==29572== Conditional jump or move depends on uninitialised value(s)
==29572== at 0x4AAFA00: vfprintf (vfprintf.c:1637)
==29572== by 0x4AB646F: printf (printf.c:33)
==29572== by 0x1088F: main (test.c:10)
==29572==
==29572== Conditional jump or move depends on uninitialised value(s)
==29572== at 0x4AAFA7C: vfprintf (vfprintf.c:1637)
==29572== by 0x4AB646F: printf (printf.c:33)
==29572== by 0x1088F: main (test.c:10)
Once I use "strlen" Valgrind seems to give me warnings about uninitialized values. Why?