Complete.Org: Mailing Lists: Archives: freeciv-dev: September 2002:
[Freeciv-Dev] Re: "division by zero" error during compilation (PR#1954)
Home

[Freeciv-Dev] Re: "division by zero" error during compilation (PR#1954)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Jason Short <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Cc: freeciv-dev@xxxxxxxxxxx, bugs@xxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: "division by zero" error during compilation (PR#1954)
From: "Ross W. Wetmore" <rwetmore@xxxxxxxxxxxx>
Date: Fri, 13 Sep 2002 10:34:15 -0400

Note, the poor interface and implementation for the macro is the problem,
not anything fundamental.

The macro has a clean safe form in the corecleanups which use rotationally
ordered directions. Here the interface defines any value which can be
wrapped to a 2*pi range or the distinct circular subset of points denoting
adjacent tiles in this implementation.

The safe version is also much faster than the "iterate over all
possibilities and choose one" approach which clearly has scalability
problems extending itself to infinitely wrapped ranges.

Cheers,
RossW

At 11:32 PM 02/09/08 -0700, Jason Short wrote:
>Raimar Falke wrote:
>> On Wed, Aug 21, 2002 at 12:16:33PM -0700, jdorje@xxxxxxxxxxxxxxxxxxxxx
wrote:
>> 
>>>If I compile FreeCiv with gcc3 and -Werror, I get
>>>
>>>gcc -DHAVE_CONFIG_H -I. -I. -I.. -I./include -I../common -I../intl 
>>>-I./agents     -g -O3 -Wpointer-arith -Wcast-align -Wmissing-prototypes 
>>>-Wmissing-declarations -Werror -g -Wall -c `test -f tilespec.c || echo 
>>>'./'`tilespec.c
>>>cc1: warnings being treated as errors
>>>tilespec.c: In function `fill_tile_sprite_array_iso':
>>>tilespec.c:1269: warning: division by zero
>>>tilespec.c:1271: warning: division by zero
>>>make[3]: *** [tilespec.o] Error 1
>
>> Another suggestion: just make the code a real function. There is no
>> need for a macro. It isn't used often.
>
>Sure, that would be fine too.
>
>One thing: in the case of an invalid direction, it's good to have an 
>assert (or alternative error checking function, as discussed elsewhere). 
>  But I don't think returning -1 or the given (invalid) direction is 
>particularly productive - the best chance for recovery of the game would 
>be to return an (arbitrary) valid direction.
>
>jason
>
>
>
>



[Prev in Thread] Current Thread [Next in Thread]