|
From: Jean-Marc V.
|
Hi, Perhaps I should explain what the code does. It's taken from the Spee= x ( http://www.speex.org/ ) codec. What it does is that in the real cod= e, the value of dist is the distance in a vector quantizer. The idea is = to compute the N smallest distance best_dist. It's normal that in the fi= rst few iterations, uninitialized values are moved around in best_dist, b= ut in the end, they are guarantied to be all gone and nothing ever depen= ds on these uninitialized values. =09Jean-Marc Le vendredi 04 mars 2005 =E0 10:29 +0100, Dimitri Papadopoulos-Orfano= s a =E9crit : > Hi, >=20 > > I'm attaching a program that demonstrates the problem. When I com= pile >=20 > Mmmh... If the code was less obfuscated, maybe I could understand i= t :-)=20 > Seriously, can't the algorithm be clarified and the code simplified= and=20 > properly indented? >=20 > > with -O0 or -O1, there's no problem, but with -O2 and above, I ge= t: >=20 > I've added a few printf's to your code to track best_dist[k]=20 > initializations. It does look like best_dist[k] is initialized usin= g=20 > unitialiazed best_dist[k-1] values. See attached modified val.c sou= rce file. >=20 > Dimitri --=20 Jean-Marc Valin <Jean-Marc.Valin@USherbrooke.ca> Universit=E9 de Sherbrooke |