bug or not

Discussion of chess software programming and technical issues.

Moderators: hgm, Harvey Williamson, bob

Forum rules
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
Post Reply
User avatar
xr_a_y
Posts: 655
Joined: Sat Nov 25, 2017 1:28 pm
Location: France

bug or not

Post by xr_a_y » Sat May 25, 2019 4:39 pm

Reading Stockfish KPK code today, I found this

Code: Select all

 // Immediate win if a pawn can be promoted without getting captured
    else if (   us == WHITE
             && rank_of(psq) == RANK_7
             && ksq[us] != psq + NORTH
             && (    distance(ksq[~us], psq + NORTH) > 1
                 || (PseudoAttacks[KING][ksq[us]] & (psq + NORTH))))
        result = WIN;
where a Bitboard PseudoAttacks[][] is used (&) with a Square psq. Isn't this a bug ?

RubiChess
Posts: 99
Joined: Fri Mar 30, 2018 5:20 am

Re: bug or not

Post by RubiChess » Sat May 25, 2019 4:54 pm

SF code uses overloading operators in several places and this is one of them:

...
inline Bitboard operator&( Bitboard b, Square s) { return b & square_bb(s); }
---

Andreas
Last edited by RubiChess on Sat May 25, 2019 4:56 pm, edited 1 time in total.

User avatar
xr_a_y
Posts: 655
Joined: Sat Nov 25, 2017 1:28 pm
Location: France

Re: bug or not

Post by xr_a_y » Sat May 25, 2019 4:56 pm

RubiChess wrote:
Sat May 25, 2019 4:54 pm
SF code uses overloading operators in several places. I guess this is one of them.

Andreas
Thanks ! this is pretty :wink:

Code: Select all

inline Bitboard  operator&( Bitboard  b, Square s) { return b &  square_bb(s); }

Post Reply