unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Procps in core-updates
@ 2023-03-18 12:32 Andreas Enge
  2023-03-18 17:38 ` Leo Famulari
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Andreas Enge @ 2023-03-18 12:32 UTC (permalink / raw)
  To: guix-devel

[-- Attachment #1: Type: text/plain, Size: 1251 bytes --]

Hello,

procps fails its tests on core-updates when built with --system=i686-linux
(it succeeds on x86_64).

The error is completely not understandable (and Debian has disabled the test).
I modified the test file as attached; my changes are to compute the value val
separately before the "if" (interestingly enough, the variable declaration
"double val;" was already there), and I added the fprintf at the beginnings
of the lines.

The test then fails and prints
CMP 1
CMP 0
DIF 0.000000
FAIL: strtod_nol_or_err("123") != 123.000000

So val != tests[i].result when the "if" is executed,
this is still the case for the first fprintf,
and then changes for the second fprintf.

Has anyone got any explanation for this behaviour? A compiler error?

Here:
   https://www.freelists.org/post/procps/strtod-nol-or-err-on-32bit-Was-procps-3312-released,2
the conclusion is
"Ive got a pending patch to just remove it. Floating point math sucks when
it comes to equality."
but this is not even floating point maths - whatever the contents of val
and tests[i].result, they should not be changed by a comparison (or an
fprintf; I can also make the test work just by adding some printf into
the strtod_nol_or_err function that is exercised by this test).

Andreas


[-- Attachment #2: test_strtod_nol.c --]
[-- Type: text/plain, Size: 1139 bytes --]


#include <stdio.h>
#include <stdlib.h>
#include "strutils.h"

struct strtod_tests {
    char *string;
    double result;
};

struct strtod_tests tests[] = {
    {"123",     123.0},
    {"-123",    -123.0},
    {"12.34",   12.34},
    {"-12.34",  -12.34},
    {".34",     0.34},
    {"-.34",    -0.34},
    {"12,34",   12.34},
    {"-12,34",  -12.34},
    {",34",     0.34},
    {"-,34",    -0.34},
    {"0",       0.0},
    {".0",      0.0},
    {"0.0",     0.0},
    {NULL, 0.0}
};



int main(int argc, char *argv[])
{
    int i;
    double val;

    for(i=0; tests[i].string != NULL; i++) {
        val = strtod_nol_or_err(tests[i].string, "Cannot parse number");
        if (val != tests[i].result) {
fprintf(stderr, "CMP %i\n", val != tests[i].result);
fprintf(stderr, "CMP %i\n", val != tests[i].result);
fprintf(stderr, "DIF %f\n", val - tests[i].result);
            fprintf(stderr, "FAIL: strtod_nol_or_err(\"%s\") != %f\n",
                    tests[i].string, tests[i].result);
            return EXIT_FAILURE;
        }
        //fprintf(stderr, "PASS: strtod_nol for %s\n", tests[i].string);
    }
    return EXIT_SUCCESS;
}

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2023-03-20 21:26 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-18 12:32 Procps in core-updates Andreas Enge
2023-03-18 17:38 ` Leo Famulari
2023-03-18 17:44   ` Andreas Enge
2023-03-19 17:36 ` Michael Schierl
2023-03-20 14:54   ` Andreas Enge
2023-03-20 20:02     ` Michael Schierl
2023-03-20 21:25       ` Andreas Enge
2023-03-19 17:49 ` Felix Lechner via Development of GNU Guix and the GNU System distribution.
2023-03-19 19:22   ` Kaelyn

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).