[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Tinycc-devel] x86_64 tcc doesn't set sign bit on NaNs
From: |
Vincent Lefevre |
Subject: |
Re: [Tinycc-devel] x86_64 tcc doesn't set sign bit on NaNs |
Date: |
Tue, 5 Jan 2021 10:27:21 +0100 |
User-agent: |
Mutt/2.0.4+66 (e4a8abe8) vl-132933 (2021-01-03) |
On 2021-01-04 04:59:28 +0100, Michael Matz wrote:
> Hello,
>
> On Mon, 4 Jan 2021, Vincent Lefevre wrote:
>
> > > -----------------------------
> > > #include <stdio.h>
> > > #include <math.h>
> > > #include <stdlib.h>
> > >
> > > int main(int argc, char **argv)
> > > {
> > > double d = strtod("-nan", NULL);
> > > d = -d;
> > > printf("%g, signbit(d) = %d\n", d, signbit(d));
> > > return 0;
> > > }
> > > -----------------------------
> > >
> > > Results:
> > >
> > > $ gcc foo.c -o foo && ./foo
> > > -nan, signbit(d) = 1
> > >
> > > $ tcc foo.c -o foo2 && ./foo2
> > > nan, signbit(d) = 0
> > >
> > > I get the same results as gcc with clang and pcc. tcc is the outlier.
> >
> > AFAIK, the status of the sign bit of a NaN is unspecified, except
> > for some particular functions, but not strtod. So I don't see a
> > bug in tcc.
> >
> > Note: for GCC, there's an inconsistency between your testcase
> > and the result.
>
> Yeah, I think that's merely a typo in Arnolds email. The inconsistency is
> there, applying unary '-' to a NaN doesn't change the sign of it in TCC.
But my point is that with the above testcase, you cannot know whether
the difference between gcc and tcc comes from strtod (which would be
valid, as strtod doesn't specify the sign or NaN) or the "d = -d;"
(which would be invalid). A printf should have been added between
the strtod and the "d = -d;" to be sure.
--
Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
- [Tinycc-devel] x86_64 tcc doesn't set sign bit on NaNs, Arnold Robbins, 2021/01/03
- Re: [Tinycc-devel] x86_64 tcc doesn't set sign bit on NaNs, arnold, 2021/01/04
- Re: [Tinycc-devel] x86_64 tcc doesn't set sign bit on NaNs,
Vincent Lefevre <=
- Re: [Tinycc-devel] x86_64 tcc doesn't set sign bit on NaNs, arnold, 2021/01/05
- Re: [Tinycc-devel] x86_64 tcc doesn't set sign bit on NaNs, ian, 2021/01/05
- Re: [Tinycc-devel] x86_64 tcc doesn't set sign bit on NaNs, Michael Matz, 2021/01/06
- Re: [Tinycc-devel] x86_64 tcc doesn't set sign bit on NaNs, grischka, 2021/01/05