Am Freitag, 24. April 2009 schrieb Kelemen Balazs:
> with --leak-check=yes this leads to a definetely lost error:
>
> int main() {
> void* p = malloc(20);
> unsigned pAsUint = reinterpret_cast<unsigned>(p);
> p = 0;
> }
>
> Is this the expected behavior of valgrind?
This is the expected behavior because you have definitively lost the pointer.
A pointer might not fit into an unsigned. Take for example any 64bit platform.
However I am not sure whether this is the expected behaviour platforms where a
pointer and an unsigned have the same size. The following program gives me
also a definitely lost error, although I would expect to have a "still
reachable"
#include <stdlib.h>
int main() {
void * p = malloc(20);
}
Christoph
------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensign option that enables unlimited
royalty-free distribution of the report engine for externally facing
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Valgrind-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/valgrind-users