On 2023-07-30 16:07:29 +0600, Viktor M wrote:
> Hello everyone. So today I stumbled upon this bug when doing math
> involving conversions between float and double. A minimal example:
[...]
Not really minimal. I could simplify it even further:
#include <stdio.h>
struct V {
int x, y, z;
};
struct V vec(void)
{
return (struct V) { 0, 0, 1 };
}
void func(float f, struct V v)
{
printf("%f\n", f);
}
int main(void)
{
float d = 5.0f;
func(d, vec());
return 0;
}
I get successively on x86_64:
-213.969727
-0.000001
-0.000000
44308718004014403453773152256.000000
Putting the 5.0f in the argument instead of d, or reducing the
struct size, or changing float to double makes the bug disappear.
--
Vincent Lefèvre <[email protected]> - 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
[email protected]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel