解释valgrind错误无效的写入大小4

cam*_*ccc 10 gcc valgrind

我最近试图追踪我正在使用valgrind的程序中的一些错误,我得到的错误之一是:

==6866== Invalid write of size 4
==6866==    at 0x40C9E2: superneuron::read(_IO_FILE*) (superneuron.cc:414)
Run Code Online (Sandbox Code Playgroud)

违规行#414读取

amplitudes__[points_read] = 0x0;
Run Code Online (Sandbox Code Playgroud)

和振幅_早先被定义为

uint32_t * amplitudes__ = (uint32_t* ) amplitudes;
Run Code Online (Sandbox Code Playgroud)

现在显然uint32_t是4个字节长,所以这是写入大小,但有人可以告诉我它为什么无效?

Mat*_*Mat 6

points_read你最有可能超出界限,你写的是你分配的内存之前(或之前) amplitudes.