TerjeKir / weiss

Weiss - a UCI chess engine
GNU General Public License v3.0
102 stars 18 forks source link

Compilation failure on Ubuntu 23.10 (GCC 13.2) #677

Closed skiminki closed 1 year ago

skiminki commented 1 year ago

Attempting to compile Weiss on Ubuntu 23.10 fails with the following error message:

ubuntu@9796d368b132:~/OpenBench/Scripts/Repositories/weiss/src$ gcc --version
gcc (Ubuntu 13.2.0-3ubuntu1) 13.2.0
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

ubuntu@9796d368b132:~/OpenBench/Scripts/Repositories/weiss/src$ make
gcc -std=gnu11 -Wall -Wextra -Wshadow -Werror -Wmissing-declarations -O3 -flto -march=native -DUSE_PEXT -DNDEBUG *.c pyrrhic/tbprobe.c tuner/*.c query/*.c noobprobe/*.c onlinesyzygy/*.c -pthread -lm -o weiss -fprofile-generate="pgo"
In file included from pyrrhic/tbprobe.c:259:
pyrrhic/tbchess.c: In function 'pyrrhic_char_to_piece_type':
pyrrhic/tbchess.c:109:34: error: comparison of integer expressions of different signedness: 'int' and 'enum <anonymous>' [-Werror=sign-compare]
  109 |     for (int i = PYRRHIC_PAWN; i <= PYRRHIC_KING; i++)
      |                                  ^~
pyrrhic/tbprobe.c: In function 'prt_str':
pyrrhic/tbprobe.c:448:36: error: comparison of integer expressions of different signedness: 'int' and 'enum <anonymous>' [-Werror=sign-compare]
  448 |     for (int pt = PYRRHIC_KING; pt >= PYRRHIC_PAWN; pt--)
      |                                    ^~
pyrrhic/tbprobe.c:454:36: error: comparison of integer expressions of different signedness: 'int' and 'enum <anonymous>' [-Werror=sign-compare]
  454 |     for (int pt = PYRRHIC_KING; pt >= PYRRHIC_PAWN; pt--)
      |                                    ^~
cc1: all warnings being treated as errors
make: *** [Makefile:80: pgo] Error 1

After a closer inspection, it seems that the anonymous enum that encapsulates the constants such as PYRRHIC_PAWN becomes unsigned, because it includes enumeration values such as PYRRHIC_PROMOSQS = 0XFF000000000000FFULL. Experimenting with godbolt, it seems that GCC 13.1 has added this check with -Wextra. Reference: https://godbolt.org/z/eW4fnKMrY