Subject: Re: bug#41279: 26.3; Calc: sum(gcd(0,n),n,-1,-1) evaluates to -1

From: Mattias Engdegård <[email-masked]>
Date: Fri, 15 May 2020 20:21:47 +0200

15 maj 2020 kl. 19.44 skrev David Ongaro <[email-masked]>:

> I see, so the simplest reproduction of the bug doesn't involve the sum, but just the evaluation of gcd(0, x) or gcd(x, 0). Your fix seems sensible to me, I don't see why you consider it a 'hack'. The simplification gcd(0, x)=gcd(x, 0)=abs(x) seems legit and matches the gcd definition "The largest positive integer that divides each of the integers".

Quite, but there is a small possibility that further simplification relies on the gcd(0,x)=x behaviour. You never know with Calc: it is complex and everything seems interconnected. After all, abs is often an obstacle in algebraic transforms; you often end up splitting cases.

That said, it's probably the right thing to do. Now pushed to master, which means that you need to build a development snapshot from source, or apply the change (60cd6cce55) to your Emacs.