Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: To Experienced Java Programmers: strange BUG!!

Author: Marek Strejczek

Date: 07:19:49 05/06/04

Go up one level in this thread


>--- snip ---
>
>      ...
>      blackLegalMoves = board.whitePieces;   // captures
>
>      ...
>      // k -- black king
>      /////////////////////
>
>      // o  normal moves and captures
>      from = board.blackKing;
>       //    (*)
>      mvboard = KING_MOVES[from] & blackLegalMoves;
>      halfply = from | Move.BPC_KING;
>      while (mvboard != 0L) {
>        to = Bitboard.last(mvboard);
>        mvboard &= Bitboard.CLEAR_MASK[to];
>        moves[mvidx++] = halfply | to << Move.TO | piece[to] << Move.CAPTY;
>      }
>
>--- snap ---
>
>if I insert System.out.println(blackLegalMoves); at point (*) and similiar
>points in the code, the error is not present -- even more strange!?!
>
>what can here go wrong with longs? code for other piece types is
>similiar...
>
>Greetings,
>           Bernd

I've noticed a similar weird behaviour in C++ Builder 5, in the part of my code
that initializes various bitboard masks. It does it inside nested loops, and
when I compile the program with optimization setting on I have some (not all)
masks corrupted. However, if I add a line

cout << "";

after some for(...) lines then the results are correct.
This problem does not appear with optimization off.
Maybe the nature of the problem is similar? I suppose that the compiler mixes
something with registers, and the function call like operator<< may clean it up.
But I'm not a compiler expert...

Regards
Marek Strejczek



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.