* [Qemu-devel] [Bug 1815423] [NEW] Incorrect floating point cast to int.
@ 2019-02-11 8:50 Vasily Dybala
2019-07-18 14:45 ` [Qemu-devel] [Bug 1815423] Re: x86_64 TCG: " Peter Maydell
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Vasily Dybala @ 2019-02-11 8:50 UTC (permalink / raw)
To: qemu-devel
Public bug reported:
I used exaample from:
https://stackoverflow.com/questions/3986795/what-is-the-result-of-casting-float-inf-inf-and-nan-to-integer-in-c
#include <stdio.h>
#include <math.h>
int main(int argc, char** argv) {
float a = INFINITY;
float b = -INFINITY;
float c = NAN;
printf("float %f %f %f\n", a, b, c);
printf("int %d %d %d\n", (int) a, (int) b, (int) c);
printf("uint %u %u %u\n", (unsigned int) a, (unsigned int) b, (unsigned int) c);
printf("lint %ld %ld %ld\n", (long int) a, (long int) b, (long int) b);
printf("luint %lu %lu %lu\n", (unsigned long int) a, (unsigned long int) b, (unsigned long int) c);
return 0;
}
And got different results on real computer and on qemu.
output from real HW is the same as on stackoverflow:
$ gcc test.c && ./a.out
float inf -inf nan
int -2147483648 -2147483648 -2147483648
uint 0 0 0
lint -9223372036854775808 -9223372036854775808 -9223372036854775808
luint 0 9223372036854775808 9223372036854775808
But on qemu I got another results:
float inf -inf nan
int 2147483647 -2147483648 2147483647
uint 4294967295 0 4294967295
lint 9223372036854775807 -9223372036854775808 -9223372036854775808
luint 18446744073709551615 9223372036854775808 9223372036854775807
qemu launch string:
/qemu-system-x86_64 -m 1024 -cpu core2duo -serial stdio -netdev user,id=network0 -device e1000,netdev=network0 -kernel my_kernel
qemu version:
x86_64-softmmu/qemu-system-x86_64 --version
QEMU emulator version 3.1.50 (v3.1.0-1676-ge47f81b617-dirty)
Copyright (c) 2003-2019 Fabrice Bellard and the QEMU Project developers
This bug affect some javascript (surprise) calculations:
var conversion = "01234567890";
var x;
var result = conversion[x & 42];
console.log(result)
In example, var x is "undefined"
and when do calculation "x & 42" on js we should get 0 (it is documented feature), but actually got "42"
and "result" sould be "0" but actually we got "undefined"
** Affects: qemu
Importance: Undecided
Status: New
** Tags: javascript js softfp
--
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1815423
Title:
Incorrect floating point cast to int.
Status in QEMU:
New
Bug description:
I used exaample from:
https://stackoverflow.com/questions/3986795/what-is-the-result-of-casting-float-inf-inf-and-nan-to-integer-in-c
#include <stdio.h>
#include <math.h>
int main(int argc, char** argv) {
float a = INFINITY;
float b = -INFINITY;
float c = NAN;
printf("float %f %f %f\n", a, b, c);
printf("int %d %d %d\n", (int) a, (int) b, (int) c);
printf("uint %u %u %u\n", (unsigned int) a, (unsigned int) b, (unsigned int) c);
printf("lint %ld %ld %ld\n", (long int) a, (long int) b, (long int) b);
printf("luint %lu %lu %lu\n", (unsigned long int) a, (unsigned long int) b, (unsigned long int) c);
return 0;
}
And got different results on real computer and on qemu.
output from real HW is the same as on stackoverflow:
$ gcc test.c && ./a.out
float inf -inf nan
int -2147483648 -2147483648 -2147483648
uint 0 0 0
lint -9223372036854775808 -9223372036854775808 -9223372036854775808
luint 0 9223372036854775808 9223372036854775808
But on qemu I got another results:
float inf -inf nan
int 2147483647 -2147483648 2147483647
uint 4294967295 0 4294967295
lint 9223372036854775807 -9223372036854775808 -9223372036854775808
luint 18446744073709551615 9223372036854775808 9223372036854775807
qemu launch string:
/qemu-system-x86_64 -m 1024 -cpu core2duo -serial stdio -netdev user,id=network0 -device e1000,netdev=network0 -kernel my_kernel
qemu version:
x86_64-softmmu/qemu-system-x86_64 --version
QEMU emulator version 3.1.50 (v3.1.0-1676-ge47f81b617-dirty)
Copyright (c) 2003-2019 Fabrice Bellard and the QEMU Project developers
This bug affect some javascript (surprise) calculations:
var conversion = "01234567890";
var x;
var result = conversion[x & 42];
console.log(result)
In example, var x is "undefined"
and when do calculation "x & 42" on js we should get 0 (it is documented feature), but actually got "42"
and "result" sould be "0" but actually we got "undefined"
To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1815423/+subscriptions
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Qemu-devel] [Bug 1815423] Re: x86_64 TCG: Incorrect floating point cast to int.
2019-02-11 8:50 [Qemu-devel] [Bug 1815423] [NEW] Incorrect floating point cast to int Vasily Dybala
@ 2019-07-18 14:45 ` Peter Maydell
2019-07-18 14:58 ` Peter Maydell
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Peter Maydell @ 2019-07-18 14:45 UTC (permalink / raw)
To: qemu-devel
** Summary changed:
- Incorrect floating point cast to int.
+ x86_64 TCG: Incorrect floating point cast to int.
--
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1815423
Title:
x86_64 TCG: Incorrect floating point cast to int.
Status in QEMU:
New
Bug description:
I used exaample from:
https://stackoverflow.com/questions/3986795/what-is-the-result-of-casting-float-inf-inf-and-nan-to-integer-in-c
#include <stdio.h>
#include <math.h>
int main(int argc, char** argv) {
float a = INFINITY;
float b = -INFINITY;
float c = NAN;
printf("float %f %f %f\n", a, b, c);
printf("int %d %d %d\n", (int) a, (int) b, (int) c);
printf("uint %u %u %u\n", (unsigned int) a, (unsigned int) b, (unsigned int) c);
printf("lint %ld %ld %ld\n", (long int) a, (long int) b, (long int) b);
printf("luint %lu %lu %lu\n", (unsigned long int) a, (unsigned long int) b, (unsigned long int) c);
return 0;
}
And got different results on real computer and on qemu.
output from real HW is the same as on stackoverflow:
$ gcc test.c && ./a.out
float inf -inf nan
int -2147483648 -2147483648 -2147483648
uint 0 0 0
lint -9223372036854775808 -9223372036854775808 -9223372036854775808
luint 0 9223372036854775808 9223372036854775808
But on qemu I got another results:
float inf -inf nan
int 2147483647 -2147483648 2147483647
uint 4294967295 0 4294967295
lint 9223372036854775807 -9223372036854775808 -9223372036854775808
luint 18446744073709551615 9223372036854775808 9223372036854775807
qemu launch string:
/qemu-system-x86_64 -m 1024 -cpu core2duo -serial stdio -netdev user,id=network0 -device e1000,netdev=network0 -kernel my_kernel
qemu version:
x86_64-softmmu/qemu-system-x86_64 --version
QEMU emulator version 3.1.50 (v3.1.0-1676-ge47f81b617-dirty)
Copyright (c) 2003-2019 Fabrice Bellard and the QEMU Project developers
This bug affect some javascript (surprise) calculations:
var conversion = "01234567890";
var x;
var result = conversion[x & 42];
console.log(result)
In example, var x is "undefined"
and when do calculation "x & 42" on js we should get 0 (it is documented feature), but actually got "42"
and "result" sould be "0" but actually we got "undefined"
To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1815423/+subscriptions
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Qemu-devel] [Bug 1815423] Re: x86_64 TCG: Incorrect floating point cast to int.
2019-02-11 8:50 [Qemu-devel] [Bug 1815423] [NEW] Incorrect floating point cast to int Vasily Dybala
2019-07-18 14:45 ` [Qemu-devel] [Bug 1815423] Re: x86_64 TCG: " Peter Maydell
@ 2019-07-18 14:58 ` Peter Maydell
2019-08-05 18:14 ` Peter Maydell
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Peter Maydell @ 2019-07-18 14:58 UTC (permalink / raw)
To: qemu-devel
** Changed in: qemu
Status: New => Confirmed
--
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1815423
Title:
x86_64 TCG: Incorrect floating point cast to int.
Status in QEMU:
Confirmed
Bug description:
I used exaample from:
https://stackoverflow.com/questions/3986795/what-is-the-result-of-casting-float-inf-inf-and-nan-to-integer-in-c
#include <stdio.h>
#include <math.h>
int main(int argc, char** argv) {
float a = INFINITY;
float b = -INFINITY;
float c = NAN;
printf("float %f %f %f\n", a, b, c);
printf("int %d %d %d\n", (int) a, (int) b, (int) c);
printf("uint %u %u %u\n", (unsigned int) a, (unsigned int) b, (unsigned int) c);
printf("lint %ld %ld %ld\n", (long int) a, (long int) b, (long int) b);
printf("luint %lu %lu %lu\n", (unsigned long int) a, (unsigned long int) b, (unsigned long int) c);
return 0;
}
And got different results on real computer and on qemu.
output from real HW is the same as on stackoverflow:
$ gcc test.c && ./a.out
float inf -inf nan
int -2147483648 -2147483648 -2147483648
uint 0 0 0
lint -9223372036854775808 -9223372036854775808 -9223372036854775808
luint 0 9223372036854775808 9223372036854775808
But on qemu I got another results:
float inf -inf nan
int 2147483647 -2147483648 2147483647
uint 4294967295 0 4294967295
lint 9223372036854775807 -9223372036854775808 -9223372036854775808
luint 18446744073709551615 9223372036854775808 9223372036854775807
qemu launch string:
/qemu-system-x86_64 -m 1024 -cpu core2duo -serial stdio -netdev user,id=network0 -device e1000,netdev=network0 -kernel my_kernel
qemu version:
x86_64-softmmu/qemu-system-x86_64 --version
QEMU emulator version 3.1.50 (v3.1.0-1676-ge47f81b617-dirty)
Copyright (c) 2003-2019 Fabrice Bellard and the QEMU Project developers
This bug affect some javascript (surprise) calculations:
var conversion = "01234567890";
var x;
var result = conversion[x & 42];
console.log(result)
In example, var x is "undefined"
and when do calculation "x & 42" on js we should get 0 (it is documented feature), but actually got "42"
and "result" sould be "0" but actually we got "undefined"
To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1815423/+subscriptions
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Qemu-devel] [Bug 1815423] Re: x86_64 TCG: Incorrect floating point cast to int.
2019-02-11 8:50 [Qemu-devel] [Bug 1815423] [NEW] Incorrect floating point cast to int Vasily Dybala
2019-07-18 14:45 ` [Qemu-devel] [Bug 1815423] Re: x86_64 TCG: " Peter Maydell
2019-07-18 14:58 ` Peter Maydell
@ 2019-08-05 18:14 ` Peter Maydell
2019-09-20 15:23 ` Peter Maydell
2020-01-09 13:23 ` Thomas Huth
4 siblings, 0 replies; 6+ messages in thread
From: Peter Maydell @ 2019-08-05 18:14 UTC (permalink / raw)
To: qemu-devel
https://patchew.org/QEMU/20190805180332.10185-1-peter.maydell@linaro.org/
is a patch which fixes the C test case (and may also fix the node.js
case, though I don't have a setup to test that).
** Changed in: qemu
Status: Confirmed => In Progress
--
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1815423
Title:
x86_64 TCG: Incorrect floating point cast to int.
Status in QEMU:
In Progress
Bug description:
I used exaample from:
https://stackoverflow.com/questions/3986795/what-is-the-result-of-casting-float-inf-inf-and-nan-to-integer-in-c
#include <stdio.h>
#include <math.h>
int main(int argc, char** argv) {
float a = INFINITY;
float b = -INFINITY;
float c = NAN;
printf("float %f %f %f\n", a, b, c);
printf("int %d %d %d\n", (int) a, (int) b, (int) c);
printf("uint %u %u %u\n", (unsigned int) a, (unsigned int) b, (unsigned int) c);
printf("lint %ld %ld %ld\n", (long int) a, (long int) b, (long int) b);
printf("luint %lu %lu %lu\n", (unsigned long int) a, (unsigned long int) b, (unsigned long int) c);
return 0;
}
And got different results on real computer and on qemu.
output from real HW is the same as on stackoverflow:
$ gcc test.c && ./a.out
float inf -inf nan
int -2147483648 -2147483648 -2147483648
uint 0 0 0
lint -9223372036854775808 -9223372036854775808 -9223372036854775808
luint 0 9223372036854775808 9223372036854775808
But on qemu I got another results:
float inf -inf nan
int 2147483647 -2147483648 2147483647
uint 4294967295 0 4294967295
lint 9223372036854775807 -9223372036854775808 -9223372036854775808
luint 18446744073709551615 9223372036854775808 9223372036854775807
qemu launch string:
/qemu-system-x86_64 -m 1024 -cpu core2duo -serial stdio -netdev user,id=network0 -device e1000,netdev=network0 -kernel my_kernel
qemu version:
x86_64-softmmu/qemu-system-x86_64 --version
QEMU emulator version 3.1.50 (v3.1.0-1676-ge47f81b617-dirty)
Copyright (c) 2003-2019 Fabrice Bellard and the QEMU Project developers
This bug affect some javascript (surprise) calculations:
var conversion = "01234567890";
var x;
var result = conversion[x & 42];
console.log(result)
In example, var x is "undefined"
and when do calculation "x & 42" on js we should get 0 (it is documented feature), but actually got "42"
and "result" sould be "0" but actually we got "undefined"
To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1815423/+subscriptions
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug 1815423] Re: x86_64 TCG: Incorrect floating point cast to int.
2019-02-11 8:50 [Qemu-devel] [Bug 1815423] [NEW] Incorrect floating point cast to int Vasily Dybala
` (2 preceding siblings ...)
2019-08-05 18:14 ` Peter Maydell
@ 2019-09-20 15:23 ` Peter Maydell
2020-01-09 13:23 ` Thomas Huth
4 siblings, 0 replies; 6+ messages in thread
From: Peter Maydell @ 2019-09-20 15:23 UTC (permalink / raw)
To: qemu-devel
This should be fixed by commit 1e8a98b53867f61da9, which will be in the
4.2 release.
** Changed in: qemu
Status: In Progress => Fix Committed
--
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1815423
Title:
x86_64 TCG: Incorrect floating point cast to int.
Status in QEMU:
Fix Committed
Bug description:
I used exaample from:
https://stackoverflow.com/questions/3986795/what-is-the-result-of-casting-float-inf-inf-and-nan-to-integer-in-c
#include <stdio.h>
#include <math.h>
int main(int argc, char** argv) {
float a = INFINITY;
float b = -INFINITY;
float c = NAN;
printf("float %f %f %f\n", a, b, c);
printf("int %d %d %d\n", (int) a, (int) b, (int) c);
printf("uint %u %u %u\n", (unsigned int) a, (unsigned int) b, (unsigned int) c);
printf("lint %ld %ld %ld\n", (long int) a, (long int) b, (long int) b);
printf("luint %lu %lu %lu\n", (unsigned long int) a, (unsigned long int) b, (unsigned long int) c);
return 0;
}
And got different results on real computer and on qemu.
output from real HW is the same as on stackoverflow:
$ gcc test.c && ./a.out
float inf -inf nan
int -2147483648 -2147483648 -2147483648
uint 0 0 0
lint -9223372036854775808 -9223372036854775808 -9223372036854775808
luint 0 9223372036854775808 9223372036854775808
But on qemu I got another results:
float inf -inf nan
int 2147483647 -2147483648 2147483647
uint 4294967295 0 4294967295
lint 9223372036854775807 -9223372036854775808 -9223372036854775808
luint 18446744073709551615 9223372036854775808 9223372036854775807
qemu launch string:
/qemu-system-x86_64 -m 1024 -cpu core2duo -serial stdio -netdev user,id=network0 -device e1000,netdev=network0 -kernel my_kernel
qemu version:
x86_64-softmmu/qemu-system-x86_64 --version
QEMU emulator version 3.1.50 (v3.1.0-1676-ge47f81b617-dirty)
Copyright (c) 2003-2019 Fabrice Bellard and the QEMU Project developers
This bug affect some javascript (surprise) calculations:
var conversion = "01234567890";
var x;
var result = conversion[x & 42];
console.log(result)
In example, var x is "undefined"
and when do calculation "x & 42" on js we should get 0 (it is documented feature), but actually got "42"
and "result" sould be "0" but actually we got "undefined"
To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1815423/+subscriptions
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug 1815423] Re: x86_64 TCG: Incorrect floating point cast to int.
2019-02-11 8:50 [Qemu-devel] [Bug 1815423] [NEW] Incorrect floating point cast to int Vasily Dybala
` (3 preceding siblings ...)
2019-09-20 15:23 ` Peter Maydell
@ 2020-01-09 13:23 ` Thomas Huth
4 siblings, 0 replies; 6+ messages in thread
From: Thomas Huth @ 2020-01-09 13:23 UTC (permalink / raw)
To: qemu-devel
** Changed in: qemu
Status: Fix Committed => Fix Released
--
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1815423
Title:
x86_64 TCG: Incorrect floating point cast to int.
Status in QEMU:
Fix Released
Bug description:
I used exaample from:
https://stackoverflow.com/questions/3986795/what-is-the-result-of-casting-float-inf-inf-and-nan-to-integer-in-c
#include <stdio.h>
#include <math.h>
int main(int argc, char** argv) {
float a = INFINITY;
float b = -INFINITY;
float c = NAN;
printf("float %f %f %f\n", a, b, c);
printf("int %d %d %d\n", (int) a, (int) b, (int) c);
printf("uint %u %u %u\n", (unsigned int) a, (unsigned int) b, (unsigned int) c);
printf("lint %ld %ld %ld\n", (long int) a, (long int) b, (long int) b);
printf("luint %lu %lu %lu\n", (unsigned long int) a, (unsigned long int) b, (unsigned long int) c);
return 0;
}
And got different results on real computer and on qemu.
output from real HW is the same as on stackoverflow:
$ gcc test.c && ./a.out
float inf -inf nan
int -2147483648 -2147483648 -2147483648
uint 0 0 0
lint -9223372036854775808 -9223372036854775808 -9223372036854775808
luint 0 9223372036854775808 9223372036854775808
But on qemu I got another results:
float inf -inf nan
int 2147483647 -2147483648 2147483647
uint 4294967295 0 4294967295
lint 9223372036854775807 -9223372036854775808 -9223372036854775808
luint 18446744073709551615 9223372036854775808 9223372036854775807
qemu launch string:
/qemu-system-x86_64 -m 1024 -cpu core2duo -serial stdio -netdev user,id=network0 -device e1000,netdev=network0 -kernel my_kernel
qemu version:
x86_64-softmmu/qemu-system-x86_64 --version
QEMU emulator version 3.1.50 (v3.1.0-1676-ge47f81b617-dirty)
Copyright (c) 2003-2019 Fabrice Bellard and the QEMU Project developers
This bug affect some javascript (surprise) calculations:
var conversion = "01234567890";
var x;
var result = conversion[x & 42];
console.log(result)
In example, var x is "undefined"
and when do calculation "x & 42" on js we should get 0 (it is documented feature), but actually got "42"
and "result" sould be "0" but actually we got "undefined"
To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1815423/+subscriptions
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2020-01-09 13:34 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-11 8:50 [Qemu-devel] [Bug 1815423] [NEW] Incorrect floating point cast to int Vasily Dybala
2019-07-18 14:45 ` [Qemu-devel] [Bug 1815423] Re: x86_64 TCG: " Peter Maydell
2019-07-18 14:58 ` Peter Maydell
2019-08-05 18:14 ` Peter Maydell
2019-09-20 15:23 ` Peter Maydell
2020-01-09 13:23 ` Thomas Huth
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).