Also on OpenBSD x64 with clang 10 ./configure --strip-binaries --with-selinux --cc=clang --prefix=/home/jullien/tinycc/static Binary directory /home/jullien/tinycc/static/bin TinyCC directory /home/jullien/tinycc/static/lib/tcc Library directory /home/jullien/tinycc/static/lib Include directory /home/jullien/tinycc/static/include Manual directory /home/jullien/tinycc/static/share/man Info directory /home/jullien/tinycc/static/share/info Doc directory /home/jullien/tinycc/static/share/doc Source path /home/jullien/tinycc C compiler clang (10.0) Target OS OpenBSD CPU x86_64 Config BSD ldl=no strip selinux Creating config.mak and config.h ... ------------ test3 ------------ --- test.ref Mon Jan 4 08:35:32 2021 +++ test.out3 Mon Jan 4 08:35:32 2021 @@ -573,7 +573,7 @@ Test 1.0 / x != 1.0 / -x returns 1 (should be 1). Test 1.0 / x != 1.0 / +y returns 1 (should be 1). Test 1.0 / x != 1.0 / -y returns 0 (should be 0). -nantest: nan -nan +nantest: -nan nan testing 'double' 0 1 1 0 0 1 1.000000 2.500000 3.500000 -1.500000 2.500000 0.400000 -1.000000 @@ -613,7 +613,7 @@ Test 1.0 / x != 1.0 / -x returns 1 (should be 1). Test 1.0 / x != 1.0 / +y returns 1 (should be 1). Test 1.0 / x != 1.0 / -y returns 0 (should be 0). -nantest: nan -nan +nantest: -nan nan testing 'long double' 0 1 1 0 0 1 1.000000 2.500000 3.500000 -1.500000 2.500000 0.400000 -1.000000 @@ -653,7 +653,7 @@ Test 1.0 / x != 1.0 / -x returns 1 (should be 1). Test 1.0 / x != 1.0 / +y returns 1 (should be 1). Test 1.0 / x != 1.0 / -y returns 0 (should be 0). -nantest: nan -nan +nantest: -nan nan 1.200000 3.400000 -5.600000 2.120000 0.500000 23000000000.000000 da=123.000000 gmake[2]: *** [Makefile:128: test3] Error 1 ------------ memtest ------------
-----Original Message----- From: Tinycc-devel [mailto:tinycc-devel-bounces+eligis=orange...@nongnu.org] On Behalf Of Christian Jullien Sent: Monday, January 04, 2021 07:18 To: tinycc-devel@nongnu.org Subject: Re: [Tinycc-devel] x86_64 tcc doesn't set sign bit on NaNs Hi Michael, The fix does not make the test suite happy, at least, on Linux Aarch64 when clang is used (gcc and tcc are Ok): ./configure --strip-binaries --with-selinux --cc=clang --prefix=/home/jullien/tinycc/static Binary directory /home/jullien/tinycc/static/bin TinyCC directory /home/jullien/tinycc/static/lib/tcc Library directory /home/jullien/tinycc/static/lib Include directory /home/jullien/tinycc/static/include Manual directory /home/jullien/tinycc/static/share/man Info directory /home/jullien/tinycc/static/share/info Doc directory /home/jullien/tinycc/static/share/doc Source path /home/jullien/tinycc C compiler clang (11.0) Target OS Linux CPU aarch64 Config strip selinux Creating config.mak and config.h ... ------------ test3 ------------ --- test.ref 2021-01-04 06:54:01.523848942 +0100 +++ test.out3 2021-01-04 06:54:03.523846911 +0100 @@ -653,7 +653,7 @@ Test 1.0 / x != 1.0 / -x returns 1 (should be 1). Test 1.0 / x != 1.0 / +y returns 1 (should be 1). Test 1.0 / x != 1.0 / -y returns 0 (should be 0). -nantest: nan nan +nantest: nan -nan 1.200000 3.400000 -5.600000 2.120000 0.500000 23000000000.000000 da=123.000000 gmake[2]: *** [Makefile:128: test3] Error 1 -----Original Message----- From: Tinycc-devel [mailto:tinycc-devel-bounces+eligis=orange...@nongnu.org] On Behalf Of Michael Matz Sent: Monday, January 04, 2021 04:59 To: tinycc-devel@nongnu.org Subject: Re: [Tinycc-devel] x86_64 tcc doesn't set sign bit on NaNs 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. While the interpretation of sign bits in NaNs isn't specified in IEEE754/854/P754, its existence is a given (in particular it talks about "the sign of a NaN", in order to say that their interpretation isn't determined :) ) Further IEEE754 recommends implementations to provide a negate(x) operation that copies x with reversed sign, that is to work on NaNs (and due to copysign needs to have observable behaviour). C99 and up specify that the unary '-' operator maps to that operation. So, I think it's pretty clear, that whatever the sign bit of NaNs is supposed to mean, it must be switchable by unary '-' when IEEE754 conformance is claimed. We currently don't claim so, but we aim for it if possible :) So the current "-0.0-x" expansion of unary '-' needs a change. It turned out to be a bit uglier than I wished for, but alas, fixed in mob. Thanks for the report, Arnold. Ciao, Michael. _______________________________________________ Tinycc-devel mailing list Tinycc-devel@nongnu.org https://lists.nongnu.org/mailman/listinfo/tinycc-devel _______________________________________________ Tinycc-devel mailing list Tinycc-devel@nongnu.org https://lists.nongnu.org/mailman/listinfo/tinycc-devel _______________________________________________ Tinycc-devel mailing list Tinycc-devel@nongnu.org https://lists.nongnu.org/mailman/listinfo/tinycc-devel