freeciv/freeciv-web

Compilation error of Freeciv C server on Ubuntu Kinetic 22.10

andreasrosdal opened this issue · 3 comments

I get this error when compiling the Freeciv C server, on Ubuntu Kinetic.
This is actually on Fciv.net, but it should be the same.

gcc (Ubuntu 12.2.0-3ubuntu1) 12.2.0
Ubuntu

default: In file included from ../freeciv/common/fc_types.h:22,
default: from ../freeciv/common/networking/connection.h:48,
default: from ../freeciv/common/game.h:33,
default: from ../freeciv/server/techtools.c:27:
default: In function ‘pick_random_tech_to_lose’,
default: inlined from ‘update_bulbs’ at ../freeciv/server/techtools.c:627:41:
default: ../freeciv/utility/bitvector.h:72:13: error: array subscript 32 is above array bounds of ‘unsigned char[32]’ [-Werror=array-bounds]
default: 72 | ((bv).vec[_BV_BYTE_INDEX(bit)] & _BV_BITMASK(bit)) != 0)
default: | ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
default: ../freeciv/server/techtools.c:680:11: note: in expansion of macro ‘BV_ISSET’
default: 680 | if (BV_ISSET(eligible_techs, i)) {
default: | ^~~~~~~~
default: ../freeciv/common/tech.h: In function ‘update_bulbs’:
default: ../freeciv/utility/bitvector.h:125:34: note: while referencing ‘vec’
default: 125 | typedef struct { unsigned char vec[_BV_BYTES(bits)]; } name
default: | ^~~
default: ../freeciv/common/tech.h:158:1: note: in expansion of macro ‘BV_DEFINE’
default: 158 | BV_DEFINE(bv_techs, A_LAST);
default: | ^~~~~~~~~
default: cc1: all warnings being treated as errors
default: [2/17] Compiling C object libfc_server.a.p/server_unithand.c.o
default: ninja: build stopped: subcommand failed.
default:
default: *************************
default: Failed to install freeciv
default: *************************

This patch seems to fix the problem:
https://github.com/fciv-net/fciv-net/blob/main/freeciv/patches/techtools_build_fix.patch

@cazfi Do you understand this issue?

cazfi commented

I think the root cause has been fixed some time ago - likely fciv.net is just using a bit too old server version.

As for your fix; while it makes code to compile, that code makes no sense. Now you check status of completely unrelated tech. I wouldn't be surprised if you're trading a compile error to a runtime crash there, as e.g. 'eligible' counter can get garbage value.

This was #522
Thanks