Here is the code:R.<q>=QQ[]
X=3*q^12 - 8*q^11 - 24*q^10 - 48*q^9 - 84*q^8 - 92*q^7 - 92*q^6 - 70*q^5 - 50*q^4 - 27*q^3 - 13*q^2 - 4*q - 1
Y=q^13 - 2*q^12 + 2*q^10 - q^9
print gcd(X,Y)
print X(1)
Here is the output:
q - 1
-510
The bug is extremely serious because it affects all computations with rational functions. It is also quite rare, I believe. I traced it down to the function _fmpz_poly_gcd_heuristic in FLINT. The bug is triggered when the heuristic algorithm fails, one of the divisibility checks fails, but still the value is returned as o.k.
The fix is easy, just one line needs to be added
if (divides) /* quotient really was exact */
{
--->>>>> divides=0;