Valgrind检测非法访问内存
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/chengqiuming/article/details/90311664 #include<iostream> #include<stdlib.h> using namespace std; void func(){ int *x=(int *)malloc( 10 * sizeof ( int ) ) ; x[10]=0; } int main(){ func(); cout<<"done"<<endl; return 0; } [root@localhost charpter05]# g++ -g 0508test.cpp -o 0508 [root@localhost charpter05]# ./0508 done [root@localhost charpter05]# valgrind ./0508 ==16719== Memcheck, a memory error detector ==16719== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al. ==16719== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright