Hey there, a friend of mine is starting C++ and asked me this apparently simple question:
Why does the following program not show me an error? ~~~~~~~ #include <iostream> using namespace std; int main () { int billy[2]; billy[4] = 42; cout << billy[4] << endl; return 0; } ~~~~~~~ My first reaction was of course to fire up valgrind and wanted to show him how memcheck helps in finding such errors. But apparently memcheck does _not_ find this error? How come? Is this a bug or a limitation that cannot be overcome? I'm running: 64Bit intel core i3 gcc (GCC) 4.8.0 valgrind-3.8.1 Compiled the above with g++ -g -O0 -Wall Is it b/c this is referencing a non-existing stack space? If I change the code to read int* billy = new int[2]; Valgrind can find the error... Cheers -- Milian Wolff m...@milianw.de http://milianw.de
signature.asc
Description: This is a digitally signed message part.
------------------------------------------------------------------------------ Precog is a next-generation analytics platform capable of advanced analytics on semi-structured data. The platform includes APIs for building apps and a phenomenal toolset for data science. Developers can use our toolset for easy data analysis & visualization. Get a free account! http://www2.precog.com/precogplatform/slashdotnewsletter
_______________________________________________ Valgrind-users mailing list Valgrind-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/valgrind-users