Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 02 Sep 2025 00:27:53 +0000
From:      bugzilla-noreply@freebsd.org
To:        bugs@FreeBSD.org
Subject:   [Bug 289232] i386 (x87) signal incorrectly reports FPE_FLTRES over FPE_FLTUND when both are present
Message-ID:  <bug-289232-227-olzMXotm7n@https.bugs.freebsd.org/bugzilla/>
In-Reply-To: <bug-289232-227@https.bugs.freebsd.org/bugzilla/>

index | next in thread | previous in thread | raw e-mail

https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=289232

--- Comment #13 from Konstantin Belousov <kib@FreeBSD.org> ---
Sorry, the pasted code has the bug, I divided larger number by smaller.
It should be reverse.  Now you could expect an underflow, but CPUs, both
Intel and AMD, report only inexact result.

I also checked it under Linux.

/* $Id$ */

#include <stdint.h>
#include <stdio.h>

static const double small_num = 1.0E-300;
static const double large_num = 1.0E+300;

int
main(void)
{
        uint16_t sw;

        __asm __volatile(
                "\tfldl large_num\n"
                "\tfldl small_num\n"
                "\tfdivp\n"
                "\tfstsw %%ax\n"
                : "=a"(sw)
                : "m"(small_num), "m"(large_num)
                : "flags"
                );
        printf("x87 FPU Status Word (FSW): 0x%04x\n", sw);
        if (sw & 0x01)
                printf("  INVALID OP\n");
        if (sw & 0x02)
                printf("  DENORMAL OPERAND\n");
        if (sw & 0x04)
                printf("  ZERO DIVIDE\n");
        if (sw & 0x08)
                printf("  OVERFLOW\n");
        if (sw & 0x10)
                printf("  UNDERFLOW\n");
        if (sw & 0x20)
                printf("  INEXACT\n");
}

-- 
You are receiving this mail because:
You are the assignee for the bug.

home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-289232-227-olzMXotm7n>