On Sun, 2013-09-29 at 13:16 +0200, Damien R wrote:
> Hi,
>
>
> I am using valgrind 3.7.0 and with the following program, valgrind
> reports no error.
>
>
> #include <iostream>
>
> struct Foo
> {
> void print()
> {
> std::cout << "foo" << std::endl;
> }
> };
>
> int main()
> {
> Foo * foo = new Foo;
> delete foo;
> foo->print();
> return 0;
> }
>
>
> Can someone explain why valgrind does not report any error?
The compiler inserts a call to foo print, but this does not
imply a dereference of foo pointer. If you add int a
in Foo, and assigns a value to a inside print, then you get an error.
Philippe
|