Skip to content

Undefined order of initialization #29

Closed

Description

@winapiadmin

The magic bitboard attacks are initialized in a undefined way that movegen::SQUARES_BETWEEN_BB is completely wrong (only if it's generated at runtime, which by default yes).

Reproduce code:

#include "attacks.h"
using namespace chess;
int _(){
assert(attacks::bishop(SQ_A1, 0)==9241421688590303744ULL&&"Well... this is a debug message, but this is a landmine that the magic bitboards are NOT initialized before this, wontwork\n");
return 0;
}
int _main=_();
int main(){ return _main; }

Output:

PS C:\Users\winapiadmin\source\repos\chesslib\build> .\a.exe
Assertion failed: attacks::bishop(SQ_A1, 0)==9241421688590303744ULL&&"Well... this is a debug message, but this is a landmine that the magic bitboards are NOT initialized before this, wontwork\n", file .\test.cpp, line 4

P/S: This depends on link order. The PR #28 works because I put the movegen.cpp after attacks.cpp; therefore, it links attacks.o(bj) before movegen.o(bj)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingcriticalSame as [bug], but worse.

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions