[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: I get a segmentation fault if I dont use printf
From: |
Paul Pluzhnikov |
Subject: |
Re: I get a segmentation fault if I dont use printf |
Date: |
Tue, 06 Jun 2006 17:07:37 -0700 |
User-agent: |
Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Jumbo Shrimp, linux) |
"aamir" <aamircheema@gmail.com> writes:
> Anyways, after using a debugger it showed me some memory leaks but I am
> unable to understand this one. Debugger message is
This isn't a leak. It's a use of uninitialized value.
> ==11474== Use of uninitialised value of size 8
> ==11474== at 0x804F03B: FindTree(AnswerPoint, AvlNode*) (avltree.cc:65)
> ==11474== by 0x8049BED: main (prog2.cc:652)
>
> And the part of avltree.cc looks like
>
> =======================================================
> Position_tree
> FindTree( AnswerPoint X, AvlTree T )
> {
> if( T == NULL )
> {
> return NULL;
> }
> if( X.distance < T->Element.distance ) // ==>debugger is
> talking about this line
So either X.distance or T->Element.distance has not been initialized.
> The line about which debugger is talking is shown in the above code.
> But I have made it pretty sure that in prog.cc at line 652 , the
> distance value is not unitialized.
Which 'distance' value have you made sure is initialized?
There are 2 values that are being compared.
Cheers,
P.S. It looks as if AnserPoint might be a struct with more than one
'double' member. If so, passing such structs by value is very
inefficient, and you should probably pass them by reference instead.
--
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.