Subject: Re: bug#49368: Guile 3.0.7 test failures on i686-linux, glibc 2.33 [core-updates]

From: Maxime Devos <[email-masked]>
Date: Tue, 06 Jul 2021 15:24:46 +0200

Ludovic Courtès schreef op za 03-07-2021 om 23:41 [+0200]:
> On current ‘core-updates’
> (ca. 39f1486efd70712416ca784f9014132644b04155), Guile 3.0.7,
> specifically (@@ (gnu packages commencement) guile-final) fails tests on
> i686-linux:
> 
> --8<---------------cut here---------------start------------->8---
> Running numbers.test
> FAIL: numbers.test: Number-theoretic division: euclidean/: mixed types: (130.0 10/7)
> FAIL: numbers.test: Number-theoretic division: euclidean/: mixed types: (130.0 -10/7)
> FAIL: numbers.test: Number-theoretic division: floor/: mixed types: (130.0 10/7)
> FAIL: numbers.test: Number-theoretic division: floor/: mixed types: (-130.0 -10/7)
> FAIL: numbers.test: Number-theoretic division: ceiling/: mixed types: (130.0 -10/7)
> FAIL: numbers.test: Number-theoretic division: ceiling/: mixed types: (-130.0 10/7)
> FAIL: numbers.test: Number-theoretic division: truncate/: mixed types: (130.0 10/7)
> FAIL: numbers.test: Number-theoretic division: truncate/: mixed types: (130.0 -10/7)
> FAIL: numbers.test: Number-theoretic division: truncate/: mixed types: (-130.0 10/7)
> FAIL: numbers.test: Number-theoretic division: truncate/: mixed types: (-130.0 -10/7)
> --8<---------------cut here---------------end--------------->8---
> 
> Note that this doesn’t happen on ‘master’ (glibc 3.31).
> 
> Ludo’.

I wondered if the implementation of the C function 'ceil' is buggy,
so I tried the following (spoiler: 'ceil' doesn't seem to be the issue,
or I need another test case:

Run "guix build --system=i686-linux -e (@@ (gnu packages commencement) guile-final) --keep-failed".
In the build directory, write to a file "test.c":

#include <stdio.h>
#include <math.h>

int
main(void)
{
  double x;
  double y;
  if (scanf("%lf %lf", &x, &y) < 0) /* < 0 is actually incorrect here */
    return 1;
  if (printf("%lf/%lf=%lf\n", x,y, x/y) < 0)
    return 1;
  if (printf("ceil(%lf/%lf)=%lf\n", x,y, ceil(x/y)) < 0)
    return 1;
  return 0;
}

Run ((exact->inexact 10/7) = 1.4285714285714286 on both master and core-updates):

$ gcc -Wall -Wextra -lm test.c -o test
$ echo "130.0 1.4285714285714286" | ./test
130.000000/1.428571=91.000000
ceil(130.000000/1.428571)=91.000000

On master, the output is:
130.000000/1.428571=91.000000
ceil(130.000000/1.428571)=91.000000
(idem)

Greetings,
Maxime.