Re: OpenBSD/Sparc status - Mailing list pgsql-hackers

From Darcy Buskermolen
Subject Re: OpenBSD/Sparc status
Date
Msg-id 200411230957.03440.darcy@wavefire.com
Whole thread Raw
In response to Re: OpenBSD/Sparc status  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: OpenBSD/Sparc status  (Michael Fuhr <mike@fuhr.org>)
Re: OpenBSD/Sparc status  (Stefan Kaltenbrunner <stefan@kaltenbrunner.cc>)
List pgsql-hackers
On November 19, 2004 10:55 am, you wrote:
> The answer is: it's a gcc bug.  The attached program should print
> x = 12.3
> y = 12.3
>
> but if compiled with -O or -O2 on Stefan's machine, I get garbage:
>
> $ gcc -O  ftest.c
> $ ./a.out
> x = 12.3
> y = 1.47203e-39
> $ gcc -v
> Reading specs from /usr/lib/gcc-lib/sparc64-unknown-openbsd3.6/3.3.2/specs
> Configured with:
> Thread model: single
> gcc version 3.3.2 (propolice)
> $

I can confirm this behavior on Solaris 8/sparc 64 as well.

bash-2.03$ gcc -O -m64 test.c
bash-2.03$ ./a.out 
x = 12.3
y = 2.51673e-42
bash-2.03$ file a.out 
a.out:          ELF 64-bit MSB executable SPARCV9 Version 1, dynamically 
linked, not stripped
bash-2.03$ gcc -v
Reading specs from /usr/local/lib/gcc-lib/sparc-sun-solaris2.8/3.3.2/specs
Configured with: ../configure --with-as=/usr/ccs/bin/as 
--with-ld=/usr/ccs/bin/ld --disable-nls
Thread model: posix
gcc version 3.3.2
bash-2.03$ gcc -m64 test.c
bash-2.03$ ./a.out 
x = 12.3
y = 12.3
bash-2.03$ gcc -m64 -02 test.c
gcc: unrecognized option `-02'
bash-2.03$ gcc -m64 -O2 test.c
bash-2.03$ ./a.out 
x = 12.3
y = 2.51673e-42
bash-2.03$ gcc -m64 -O3 test.c
bash-2.03$ ./a.out 
x = 12.3
y = 12.3
bash-2.03$ 


>
>             regards, tom lane
>
>
> #include <stdio.h>
>
> float
> returnfloat(float *x)
> {
>     return *x;
> }
>
> int
> main()
> {
>     float x = 12.3;
>     union {
>         float f;
>         char *t;
>     } y;
>
>     y.f = returnfloat(&x);
>
>     printf("x = %g\n", x);
>     printf("y = %g\n", y.f);
>
>     return 0;
> }
>
> ---------------------------(end of broadcast)---------------------------
> TIP 9: the planner will ignore your desire to choose an index scan if your
>       joining column's datatypes do not match

-- 
Darcy Buskermolen
Wavefire Technologies Corp.
ph: 250.717.0200
fx:  250.763.1759
http://www.wavefire.com


pgsql-hackers by date:

Previous
From: David Fetter
Date:
Subject: Re: Beta5 now Available
Next
From: Michael Fuhr
Date:
Subject: Re: another plperl bug