|
From: Dennis L. <pla...@in...> - 2005-03-03 11:10:37
|
Am Donnerstag, den 03.03.2005, 04:22 -0500 schrieb Jean-Marc Valin:
> Hi,
>
> I have the following code, for which valgrind reports an error, although
> it is perfectly valid:
>
> used=0;
> if (i<N || dist<best_dist[N-1])
> {
> //Error reported
> for (k=N-1; (k >= 1) && (k > used || dist < best_dist[k-1]); k--)
> {
> best_dist[k]=best_dist[k-1];
> nbest[k] = nbest[k-1];
> }
> best_dist[k]=dist;
> nbest[k]=i;
> used++;
> }
>
> what seems to be causing the problem is that best_dist is not
> initialized. However initialization should not be necessary because the
> part before the ||
>
> Jean-Marc
Since we dont know what types the variables are, and what values they
have, and in which case valgrind reports an error, we cannot say much to
this case. We can see more if you give us an example, which we can
compile, link and run without modifying it.
greets
Dennis
|