tinycc-devel
[Top][All Lists]
Advanced

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

Re: [Tinycc-devel] sinf/sin problems


From: Mads
Subject: Re: [Tinycc-devel] sinf/sin problems
Date: Wed, 24 Dec 2014 07:13:29 +0100

I use tcc as a part of a numerical framework on Windows.
I can confirm that:
- sinf does not work 
- some math functions (not just limited to sin) do not announce as undeclared when math.h is missing. Instead these undeclared math functions return strange values. In my case, sin(1.0) returns 639.0 when math.h is missing. Apart from a wrong return value, the framework malfunctions (following function calls are unpredictable), suggesting that the memory is messed up.

Indeed sizeof sin(1.0) is 8 when math.h is included and 4 when it is not (which should correspond to float). My best guess is that printf tries to display a 4 byte as an 8 byte value, hence the wrong output (and memory mess-up). This is indeed toxic and requires a fix, and I hope a qualified someone is able to resolve this issue.

~Mads

2014-12-24 3:08 GMT+01:00 Oleg N. Cher <address@hidden>:
Hi all,

float version sinf does not work as expected:

#include <stdio.h>
#include <math.h>

int main(int argc, char **argv) {
 float f = sinf(0.1);
 printf("%f", f);
 return 0;
}

>tcc testsinf.c
tcc: error: undefined symbol 'sinf'



Next question is a very evil problem, I think. if #include <Math> not specified, absolutely no bugs/warnings, but code works wrong:


#include <stdio.h>

int main(int argc, char **argv) {

 printf("\n%f", sin(-3.0));
 printf("\n%f", sin(-2.0));
 printf("\n%f", sin(-1.0));
 printf("\n%f", sin(0.0));
 printf("\n%f", sin(1.0));
 printf("\n%f", sin(2.0));
 printf("\n%f", sin(3.0));
 printf("\n%f", sin(3.1415926));

 return 0;
}

>tcc testsinf.c
>testsinf.exe

0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000

Please agree with me that this must be fixed.

Thank you.


--
Oleg

_______________________________________________
Tinycc-devel mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


reply via email to

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