--- Begin Message ---
Subject: |
Bug#698351: tcc: FE_INVALID flag not set on comparison with NAN (unordered) |
Date: |
Thu, 17 Jan 2013 15:40:31 +0100 |
User-agent: |
Mutt/1.5.21-6288-vl-r57386 (2013-01-17) |
Package: tcc
Version: 0.9.26~git20120612.ad5f375-6
Severity: normal
TCC doesn't set the FE_INVALID flag on comparison with NAN (<=, >=, <, >),
at least on amd64, e.g. with:
#include <stdio.h>
#include <math.h>
#include <fenv.h>
#pragma STDC FENV_ACCESS ON
int main (void)
{
double d = NAN;
volatile double v = NAN;
int err = 0;
feclearexcept (FE_INVALID);
if (d <= 0.0)
{
printf ("NAN comparison is wrong (1)\n");
err = 1;
}
if (! fetestexcept(FE_INVALID))
{
printf ("The FE_INVALID flag is not set (1)\n");
err = 1;
}
feclearexcept (FE_INVALID);
if (v <= 0.0)
{
printf ("NAN comparison is wrong (2)\n");
err = 1;
}
if (! fetestexcept(FE_INVALID))
{
printf ("The FE_INVALID flag is not set (2)\n");
err = 1;
}
feclearexcept (FE_INVALID);
v <= 0.0;
if (! fetestexcept(FE_INVALID))
{
printf ("The FE_INVALID flag is not set (3)\n");
err = 1;
}
return err;
}
I get:
$ tcc nancmp.c -o nancmp -lm
$ ./nancmp
The FE_INVALID flag is not set (1)
The FE_INVALID flag is not set (2)
The FE_INVALID flag is not set (3)
Like GCC (which is affected by the same bug), the problem is that
tcc uses ucomisd instead of comisd for <=, >=, <, >.
-- System Information:
Debian Release: 7.0
APT prefers unstable
APT policy: (500, 'unstable'), (500, 'testing'), (500, 'stable'), (1,
'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386
Kernel: Linux 3.2.0-4-amd64 (SMP w/8 CPU cores)
Locale: LANG=POSIX, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Versions of packages tcc depends on:
ii dpkg 1.16.9
ii install-info 4.13a.dfsg.1-10
ii libc6 2.13-38
Versions of packages tcc recommends:
ii libc6-dev [libc-dev] 2.13-38
tcc suggests no packages.
-- no debconf information
--- End Message ---