[Coin-discuss] arithmetic exception when using Cbc
Matthew Saltzman
mjs at clemson.edu
Thu Nov 2 17:05:38 EST 2006
On Thu, 2 Nov 2006, Michael Hennebry wrote:
> On Thu, 2 Nov 2006, Matthew Saltzman wrote:
>
>> On Thu, 2 Nov 2006, Kish Shen wrote:
>
>>> I am getting an arithmetic exception when using Cbc/Clp through OsiClp.
>>> The crash happens in CbcModel.cpp, in gcd (line 84 in the copy I am
>>> using):
>>>
>>> while (remainder) {
>>> remainder = b % a;
>>> b = a;
>>> a = remainder;
>>> }
>>> return b;
>>>
>>> The crash happens in doing the % operation, I assume because a = -1.
>
> ???
> x % -1 == 0
> It seems to me that the loop must have been entered with a==0.
> Otherwise a==remainder!=0 when the mod is taken.
> There is no other place for an arithmetic exception
> unless one is using a machine on which some values
> cannot be copied or cannot be tested.
The snippet above the one quoted has a guard against entering the loop
with a == 0. It returns b if b != 0 or aborts.
>
>> Seems like an arithmetic exception should be easy to find. Do you know
>> what the args are that cause the crash? What arch is this on?
>>
>> One thing about / and % in C (resp. C++) is that they are ambiguous. The
>> standard requires that (a/b) * b + a % b = a, but it does not require that
>> a % b >= 0, Some architectures return negative remainders if the dividend
>> or divisor is negative.
>>
>> On SPARC, for example, -4 % -6 == -4, -4 % 6 == -4, 4 % -6 == 4.
>
>
--
Matthew Saltzman
Clemson University Math Sciences
mjs AT clemson DOT edu
http://www.math.clemson.edu/~mjs
More information about the Coin-discuss
mailing list