<URL: http://bugs.freeciv.org/Ticket/Display.html?id=40610 >
2009/2/24 Marko Lindqvist:
> 2009/2/23 Marko Lindqvist:
>>
>> 2009/2/14 Chris Snook:
>>>
>>> I'm using freeciv-2.1.8-1.fc10.i386 from Fedora 10, and it disconnects
>>> from the server (because the server is crashing) as soon as I make a
>>> city, and sometimes when exploring a village (presumably when that
>>> village ends up being a friendly city).
>>
>> This definitely looks like gcc bug. Attached workaround patch fixed
>> it for me on virtual Fedora 10 server.
>
> This version of the patch works also with --disable-debug (default)
And third version avoids log spamming. This should be ready for commit.
- ML
diff -Nurd -X.diff_ignore freeciv/common/aicore/cm.c freeciv/common/aicore/cm.c
--- freeciv/common/aicore/cm.c 2009-01-22 13:16:18.000000000 +0200
+++ freeciv/common/aicore/cm.c 2009-02-24 13:39:07.000000000 +0200
@@ -1042,14 +1042,23 @@
{
int i, j; /* i is the index we read, j is the index we write */
struct tile_type_vector tofree;
+ bool forced_loop = FALSE;
/* We collect the types we want to remove and free them in one fell
swoop at the end, in order to avoid memory errors. */
tile_type_vector_init(&tofree);
- for (i = 0, j = 0; i < lattice->size; i++) {
+ /* forced_loop is workaround for what seems like gcc optimization
+ * bug.
+ * This applies to -O2 optimization on some distributions. */
+ if (lattice->size > 0) {
+ forced_loop = TRUE;
+ }
+ for (i = 0, j = 0; i < lattice->size || forced_loop; i++) {
struct cm_tile_type *ptype = lattice->p[i];
+ forced_loop = FALSE;
+
if (ptype->lattice_depth >= pcity->size) {
tile_type_vector_add(&tofree, ptype);
} else {
_______________________________________________
Freeciv-dev mailing list
[email protected]
https://mail.gna.org/listinfo/freeciv-dev