snd_mix.c (SND_InitScaletable): fixed the snd_scaletable init breakage with

gcc-4.1 and -O1 and higher From Kevin Shanahan (Tyrann). although the bug is
fixed in gcc, it is safer to have this workaround here.


git-svn-id: svn+ssh://svn.code.sf.net/p/quakespasm/code/trunk@70 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
sezero 2010-02-20 00:25:33 +00:00
parent cc83310a03
commit e4f5aa6caa

View file

@ -238,8 +238,17 @@ void SND_InitScaletable (void)
int i, j;
for (i=0 ; i<32 ; i++)
{
for (j=0 ; j<256 ; j++)
snd_scaletable[i][j] = ((signed char)j) * i * 8;
/* When compiling with gcc-4.1.0 at optimisations O1 and
higher, the tricky signed char type conversion is not
guaranteed. Therefore we explicity calculate the signed
value from the index as required. From Kevin Shanahan.
See: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26719
*/
// snd_scaletable[i][j] = ((signed char)j) * i * 8;
snd_scaletable[i][j] = ((j < 128) ? j : j - 0xff) * i * 8;
}
}