unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Andreas Enge <andreas@enge.fr>
To: guix-devel@gnu.org
Subject: Procps in core-updates
Date: Sat, 18 Mar 2023 13:32:59 +0100	[thread overview]
Message-ID: <ZBWve8oVF1s6NDav@jurong> (raw)

[-- 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;
}

             reply	other threads:[~2023-03-18 12:33 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-18 12:32 Andreas Enge [this message]
2023-03-18 17:38 ` Procps in core-updates 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZBWve8oVF1s6NDav@jurong \
    --to=andreas@enge.fr \
    --cc=guix-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).