This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: bug: returning a float doesn't work


On Wed, May 09, 2001 at 06:22:52PM +0000, Juan Carlos Pizarro M?ndez wrote:
> 
> float f(float x) {  /* this function doesn't 
> work */
>   return ((x * x) / 2.0);
> } /* float is impossible into %eax% until now 
> */
> 
> void g(float *y,float x) { /* it does work */
>   *y = ((x * x) / 2.0);
> }
> 
> main() {
>   float y = 0.0;
>   y = f(3.0);
>   printf("%f\n",y); /* fail */
>   g(&y,3.0);
>   printf("%f\n",y); /* ok */
> }
> 

$ gcc test.c
$ ./a.out
4.500000
4.500000

with all of
2.95.4 20010502 (Debian prerelease)
3.0 20010506 (prerelease)
3.1 20010507 (experimental)

The only change I made to your code was to add an #include <stdio.h>
at the top.  I believe that the program is correct and compiled
correctly, except of course that you fall off the end of main.

I do not know what "float is impossible into %eax% until now" means.
It's possible that you are confused because float values are returned
in %st(0), not %eax, on ix86 machines.

-- 
zw      ...It's not easy for cognitive scientists to get grants if they
        are working on questions of any theoretical interest.  (To ensure
        this is a main function of the institution of peer review.)
        	-- Jerry Fodor, _The Mind Doesn't Work That Way_


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]