--- In [email protected], Paul Herring <pauljherr...@...> wrote: > > http://valgrind.org/docs/manual/quick-start.html#quick-start.mcrun
As well as run-time checking, you can also catch some errors before running your code using tools such as Gimpel's lint. See: http://www.gimpel-online.com/OnlineTesting.html Select 'Do-It-Yourself Example (C++)', and copy/paste your code into the window. Hit 'Analyze Code', and you get: 23 for(j=0; j<(SIZE+EXTRA); j++) _ 24 i[j] = j ; diy.cpp 24 Warning 662: Possible creation of out-of-bounds pointer (58 beyond end of data) by operator '[' [Reference: file diy.cpp: lines 15, 23, 24] diy.cpp 24 Warning 661: Possible access of out-of-bounds pointer (58 beyond end of data) by operator '[' [Reference: file diy.cpp: lines 15, 23, 24] 25 26 for(j=0; j<(SIZE+EXTRA); j++) _ 27 cout << "\t" << j << " : "<< i[j] << endl ; diy.cpp 27 Warning 662: Possible creation of out-of-bounds pointer (58 beyond end of data) by operator '[' [Reference: file diy.cpp: lines 15, 26, 27] diy.cpp 27 Warning 661: Possible access of out-of-bounds pointer (58 beyond end of data) by operator '[' [Reference: file diy.cpp: lines 15, 26, 27] 28 29 free(i) ; 30 31 cout << "after freeing memory ..... " << endl ; 32 33 for(j=0; j<(SIZE+EXTRA); j++) _ 34 cout << "\t" << j << " : "<< i[j] << endl ; diy.cpp 34 Warning 449: Pointer variable 'i' previously deallocated [Reference: file diy.cpp: line 29] diy.cpp 34 Warning 662: Possible creation of out-of-bounds pointer (58 beyond end of data) by operator '[' [Reference: file diy.cpp: lines 15, 33, 34] diy.cpp 34 Warning 661: Possible access of out-of-bounds pointer (58 beyond end of data) by operator '[' [Reference: file diy.cpp: lines 15, 33, 34]
