AI: Danger overflows at military_advisor_choose_build()
S3_1 , d7b47462748ff2e3c0d
I have applied patches form parent ticket #46286 0002-AI-Make-kill_desire-to-handle-want-as-adv_want.patch(8KB) S3_1
I still have this overflow (which i did not mention the first time, as it appeared later)
../../../ai/default/daimilitary.c:1793:20: runtime error: signed integer overflow
Reply To alain_bkr
S3_1 , d7b47462748ff2e3c0d I have applied patches form parent ticket #46286 0002-AI-Make-kill_desire-to-handle-want-as-adv_want.patch(8KB) S3_1 I still have this overflow (which i did not mention the first time, as it appeared later)
../../../ai/default/daimilitary.c:1793:20: runtime error: signed integer overflow
I think it's the same, with some lines added by the patches that have gone in.
ok .
I am a bit puzzled by these overflows.
This one is a percentage
/* First determine the danger. It is measured in percents of our * defensive strength, capped at 200 + urgency */ if (qdanger >= our_def) { if (urgency == 0) { /* Don't waste money */ danger = 100; } else if (our_def == 0) { danger = 200 + urgency; } else { danger = MIN(200, 100 * qdanger / our_def) + urgency; }
overflow means qdanger > 200 millions , (or urgency > 2 billions )
i wonder how this can happen, and if it is not just the tip of the iceberg.
From https://osdn.net/projects/freeciv/ticket/46286#comment:12505:46286:1679918727 reported by alain_bkr:
30 ../../../ai/default/daimilitary.c:1784:20: runtime error: signed integer overflow
3 ../../../ai/default/daimilitary.c:1787:22: runtime error: signed integer overflow
This is with S3_1. Later branches have changed things around there, so this isn't necessarily relevant for them.