Computer Chess Club Archives


Search

Terms

Messages

Subject: Strange bug, please help

Author: José Carlos

Date: 17:04:35 12/08/02


  I'm trying a C version of Kogge-Stone algorithm in my bitboard engine.
  After some testing, I noticed the release version (MSVC) provided different
results than debug version. It took me quite some time to find the place where
they behave different, it happens in the DownAttacks() function.
  I found that disabling function inlining the release version worked like the
debug version.
  Then I copied the function inside the code where it was used, and declared
some local variables for not modifying the function parameters. Here's the
relevant code:

************************************************************************

	if (pPos->u64TorresN)
	{
		UINT64 u64Pieza = pPos->u64PeonesN;
		UINT64 u64Vacias = BB_TABLEROLLENO;

		u64Pieza |= (u64Pieza >>  8) & u64Vacias;
		u64Vacias &= (u64Vacias >>  8);
		u64Pieza |= (u64Pieza >> 16) & u64Vacias;
		u64Vacias &= (u64Vacias >> 16);
		u64Pieza |= (u64Pieza >> 32) & u64Vacias;
		fprintf(pFLog,"--- PI: %I64u\n",u64Pieza);
		u64Pieza = u64Pieza >> 8;

		u64ColumnasAbiertas = u64Pieza;
		fprintf(pFLog,"--- CA: %I64u\n",u64ColumnasAbiertas);
		u64ColumnasAbiertas = ~u64ColumnasAbiertas;
		fprintf(pFLog,"--- CA: %I64u\n",u64ColumnasAbiertas);
		u64ColumnasAbiertas &= au64FrontalReyBlanco[u32CasillaRey];
		fprintf(pFLog,"+++ CA: %I64u\n",u64ColumnasAbiertas);
	}

************************************************************************

  With the first printf there, the output is correct:

--- PI: 72057594037927935
--- CA: 281474976710655
--- CA: 18446462598732840960
+++ CA: 0

  For both versions. The PI bitmap looks like (X = 1; . = 0):

........
XXXXXXXX
XXXXXXXX
XXXXXXXX
XXXXXXXX
XXXXXXXX
XXXXXXXX
XXXXXXXX


  If I put the first printf one line later, debug version output is (correct):

--- PI: 281474976710655
--- CA: 281474976710655
--- CA: 18446462598732840960
+++ CA: 0

PI:
........
........
XXXXXXXX
XXXXXXXX
XXXXXXXX
XXXXXXXX
XXXXXXXX
XXXXXXXX

  But the release version is (wrong):

--- PI: 281474976645120
--- CA: 281474976645120
--- CA: 18446462598732906495
+++ CA: 1792

PI:
........
........
XXXXXXXX
XXXXXXXX
XXXXXXXX
XXXXXXXX
........
........

  Any ideas why this is happening?
  I'm tired and going to bed now...

  José C.



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.