[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] Request for "fix float to u64 intrinsics"

From: Herman ten Brugge
Subject: Re: [Tinycc-devel] Request for "fix float to u64 intrinsics"
Date: Sat, 12 Sep 2020 07:52:44 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0

I sent this in a private mail to Kyryl but it probably should also be sent to the list.

After 'add tests for float conversions to u64' I get the following output:

x86_64 (linux + macos): ok

x86_64 (windows), i386 (linux + windows):
--- 22_floating_point.expect    2020-09-11 19:25:04.775174826 +0200
+++ 22_floating_point.output    2020-09-11 20:54:23.583325674 +0200
@@ -17,6 +17,6 @@

arm, arm64, riscv64:
--- 22_floating_point.expect    2020-09-11 19:49:40.034917990 +0200
+++ 22_floating_point.output    2020-09-11 20:58:33.768829655 +0200
@@ -17,6 +17,6 @@

The test code only works 2 targets. The other 6 are broken now.



On 2020-09-11 13:11, Kyryl Melekhin wrote:
If this is undefined behavior, then this line is straight up also UB.
And because that line is UB, then it causes even more bugs down the drain.
At least if the output for this UB matches what other compilers generate
some bugs can be eliminated. But what gets me the most is why doesn't
gcc or clang compiler warn on any of this. Also how come we can't
represent a 32 bit
float in a 64 bit number? On x86_64 we sure can. Then you are citing ISO 17
while we don't even have full support for C11.

пт, 11 сент. 2020 г. в 14:43, Vincent Lefevre <vincent@vinc17.net>:
On 2020-09-11 10:32:06 +0000, Kyryl Melekhin wrote:
I guess I'll explain the bug here as well.
consider this code:

float a = -123.987;
printf("%lu", (unsigned long int)a);

Before the patch output would be 123.
After the patch output would be 18446744073709551493.
There's no bug. That's undefined behavior (see ISO C17,
because -123 is not representable in unsigned long int. So, any
behavior is correct.

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 mailing list


reply via email to

[Prev in Thread] Current Thread [Next in Thread]