Author: Dann Corbit
Date: 13:15:34 12/31/01
Go up one level in this thread
On December 31, 2001 at 15:47:25, Scott Gasch wrote:
>Hi all,
>
>I'm pulling my hair out right now with what looks like an MSVC code gen bug.
>Would someone please sanity check the following code? Maybe I'm missing
>something?
>
> j = 1;
> do
> {
> ASSERT(j > 0);
> ASSERT(j < 9);
>
> if (pHash->iFiles[WHITE][j] != 0)
> {
> //
> // Look for White doubled and tripled (etc...) pawns.
> //
> ASSERT(pHash->iFiles[WHITE][j] >= 0);
> ASSERT(pHash->iFiles[WHITE][j] <= 8);
Oddly, this assert set looks inconsistent with the above. If files are allowed
to range from 0 to 8 inclusive, why are you checking for 1 to 8 above?
> if (pHash->iFiles[WHITE][j] > 1)
> {
> iDoubled[WHITE] += pHash->iFiles[WHITE][j];
> }
>
> //
> // We can detect White isolated pawns by looking at files.
> //
> if ((pHash->iFiles[WHITE][j - 1] == 0) &&
> (pHash->iFiles[WHITE][j + 1] == 0))
> {
> //
> // It's isolated, see if it's exposed.
> //
> if (pHash->iFiles[BLACK][j] == 0)
> {
>#ifdef DEVAL
> EvalTrace(WHITE, PAWN, 0, g_iIsolatedExposedPawn,
> "isolated exp file %c",
> 'A' + j - 1);
>#endif
> iScore[WHITE] += g_iIsolatedExposedPawn;
> }
> iIsolated[WHITE] += pHash->iFiles[WHITE][j];
> ASSERT(iScore[WHITE] < 1500);
> }
>
> //
> // Look for passed pawns...
> //
I would add:
ASSERT(j <= 8);
ASSERT(j >= 0); // Or as appropriate here, if only 1 is allowed...
// Why check again? Possible memory over-write.
// That will cause all sorts of naughty things to happen.
> i = pHash->iRanks[WHITE][j];
> ASSERT(i > 1);
> ASSERT(i < 8);
>
>This last bit (i = pHash->iRanks[WHITE][j]) is causing an access violation.
[snip]
Once in a great while, I find a real compiler bug. But they are quite rare
now-days. I rather suspect there is memory stomping going on somewhere.
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.