[Bug 289232] i386 (x87) signal incorrectly reports FPE_FLTRES over FPE_FLTUND when both are present
Date: Tue, 02 Sep 2025 00:15:37 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=289232
--- Comment #12 from Konstantin Belousov <kib@FreeBSD.org> ---
Lets remove the fpu exception handler from the picture at all.
I modified your demonstrator in the following way, making it simply read the
status word after the divide, and not unmasking any fpu exceptions:
/* $Id$ */
#include <stdint.h>
#include <stdio.h>
static const double small_num __used = 1.0E-300;
static const double large_num __used = 1.0E+300;
int
main(void)
{
uint16_t sw;
__asm __volatile(
"\tfldl small_num\n"
"\tfldl large_num\n"
"\tfdivp\n"
"\tfstsw %%ax\n"
: "=a"(sw)
:
: "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");
}
The output is
exa% ./pr289232-noexcept
x87 FPU Status Word (FSW): 0x3a20
INEXACT
In other words, if anything masks the UNDERFLOW bit, it is the CPU.
--
You are receiving this mail because:
You are the assignee for the bug.