|
From: Tom H. <to...@co...> - 2013-09-29 13:32:48
|
On 29/09/13 12:16, Damien R wrote:
> 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?
Yes. Nothing in the "foo->print()" call actually accesses any memory
that was part of the object.
The body of the function doesn't access any member variables, and it's
not a virtual function so the vtable is not read, so there is no access
to any freed memory.
Tom
--
Tom Hughes (to...@co...)
http://compton.nu/
|