[Freeciv-Dev] Re: (PR#6781) Cleanups
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://rt.freeciv.org/Ticket/Display.html?id=6781 >
Gregory Berkolaiko wrote:
> <URL: http://rt.freeciv.org/Ticket/Display.html?id=6781 >
>
> On Thu, 6 Nov 2003 rt@xxxxxxxxxxx wrote:
>
>
>>2)
>>ai/aiunit.c:591:134: Expression has undefined behavior (left operand
>>uses errno, modified by right operand): log(most_desirable / ((((100 *
>>5 * 81 + 100 * (9 - 5) * 51) + 1) + 1) + (100 * 5 * 81 + 100 * (9 - 5)
>>* 51))) / log(0.6)
>>Code has unspecified behavior. Order of evaluation of function
>>parameters or subexpressions is not defined, so if a value is used and
>>modi fied in different places not separated by a sequence point
>>constraining evaluation order, then the result of the expression is
>>unspecified.
>
>
> I do not understand this error at all. Mathmatically, the order of
> evaluation is well defined.
Presumably log is a macro which modifies the value of errno. It is
illegal to do this multiple times within the same "sequence".
Seems like a bug in the implementation of log, to me. The way to work
around it would be
a = log (...)
b = log (...)
a / b
although complaining to the library writers is probably just as good of
a solution.
jason
- [Freeciv-Dev] Re: (PR#6781) Cleanups, Gregory Berkolaiko, 2003/11/09
- [Freeciv-Dev] Re: (PR#6781) Cleanups, Raimar Falke, 2003/11/09
- [Freeciv-Dev] Re: (PR#6781) Cleanups, Gregory Berkolaiko, 2003/11/09
- [Freeciv-Dev] Re: (PR#6781) Cleanups, Raimar Falke, 2003/11/09
- [Freeciv-Dev] Re: (PR#6781) Cleanups,
Jason Short <=
- [Freeciv-Dev] Re: (PR#6781) Cleanups, Raimar Falke, 2003/11/09
- [Freeciv-Dev] Re: (PR#6781) Cleanups, Raimar Falke, 2003/11/13
|
|