* Irix6 casting long double to double yields bogus results
@ 2003-01-29 19:06 Kaveh R. Ghazi
2003-01-30 9:05 ` Alexandre Oliva
0 siblings, 1 reply; 4+ messages in thread
From: Kaveh R. Ghazi @ 2003-01-29 19:06 UTC (permalink / raw)
To: aoliva; +Cc: gcc-bugs, gcc
Alex,
I've been running some tests on irix6 floating point and noticed a
problem. Casting from long double to double seems to be broken now.
Thoughts?
Thanks,
--Kaveh
%cat foo.c
#include <stdio.h>
int main()
{
long double a = 1234.5678L, b = 1234.5678L;
double c = 1234.5678;
printf ("%f %Lf %f\n", (double) a, b, c);
return 0;
}
%gcc -v
Reading specs from /var/tmp/gcc-testing/branch/build/gcc/specs
Configured with: ../egcc-3.3-CVS20030129/configure --verbose
--enable-languages=c,objc,c++,f77,java
Thread model: single
gcc version 3.3 20030129 (prerelease)
%gcc -Wformat foo.c
%./a.out
1834810029.000000 1234.567800 1234.567800
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Irix6 casting long double to double yields bogus results
2003-01-29 19:06 Irix6 casting long double to double yields bogus results Kaveh R. Ghazi
@ 2003-01-30 9:05 ` Alexandre Oliva
2003-01-30 18:33 ` Kaveh R. Ghazi
0 siblings, 1 reply; 4+ messages in thread
From: Alexandre Oliva @ 2003-01-30 9:05 UTC (permalink / raw)
To: Kaveh R. Ghazi; +Cc: gcc-bugs, gcc, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 566 bytes --]
On Jan 29, 2003, "Kaveh R. Ghazi" <ghazi@caip.rutgers.edu> wrote:
> I've been running some tests on irix6 floating point and noticed a
> problem. Casting from long double to double seems to be broken now.
I doubt it ever worked with software-emulated 128-bit long doubles :-(
I hate the convoluted logic we use to decide whether to declare the
__make_[sdt]f functions. I'm checking this obvious patch in for now,
but it would be really nice to clean it up and consolidate the several
duplicate declarations into more logical conditions. Permission to
proceed?
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: long-double-to-double.patch --]
[-- Type: text/x-patch, Size: 685 bytes --]
Index: gcc/ChangeLog
from Alexandre Oliva <aoliva@redhat.com>
* config/fp-bit.h (__make_dp): Declare if TMODES.
Index: gcc/config/fp-bit.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/fp-bit.h,v
retrieving revision 1.9
diff -u -p -r1.9 fp-bit.h
--- gcc/config/fp-bit.h 26 Jan 2003 10:06:57 -0000 1.9
+++ gcc/config/fp-bit.h 30 Jan 2003 04:17:06 -0000
@@ -521,6 +521,7 @@ extern TFtype df_to_tf (DFtype);
#endif /* ! FLOAT */
#ifdef TMODES
+extern DFtype __make_dp (fp_class_type, unsigned int, int, UDItype);
extern TFtype __make_tp (fp_class_type, unsigned int, int, UTItype);
#ifdef TFLOAT
#if defined(L_tf_to_sf)
[-- Attachment #3: Type: text/plain, Size: 289 bytes --]
--
Alexandre Oliva Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer aoliva@{redhat.com, gcc.gnu.org}
CS PhD student at IC-Unicamp oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist Professional serial bug killer
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Irix6 casting long double to double yields bogus results
2003-01-30 9:05 ` Alexandre Oliva
@ 2003-01-30 18:33 ` Kaveh R. Ghazi
2003-02-03 13:29 ` Alexandre Oliva
0 siblings, 1 reply; 4+ messages in thread
From: Kaveh R. Ghazi @ 2003-01-30 18:33 UTC (permalink / raw)
To: aoliva; +Cc: gcc-bugs, gcc-patches, gcc
> From: Alexandre Oliva <aoliva@redhat.com>
>
> On Jan 29, 2003, "Kaveh R. Ghazi" <ghazi@caip.rutgers.edu> wrote:
>
> > I've been running some tests on irix6 floating point and noticed a
> > problem. Casting from long double to double seems to be broken now.
>
> I doubt it ever worked with software-emulated 128-bit long doubles :-(
> I hate the convoluted logic we use to decide whether to declare the
> __make_[sdt]f functions. I'm checking this obvious patch in for now,
>
> * config/fp-bit.h (__make_dp): Declare if TMODES.
>
> RCS file: /cvs/gcc/gcc/gcc/config/fp-bit.h,v
> retrieving revision 1.9
> diff -u -p -r1.9 fp-bit.h
> --- gcc/config/fp-bit.h 26 Jan 2003 10:06:57 -0000 1.9
> +++ gcc/config/fp-bit.h 30 Jan 2003 04:17:06 -0000
> @@ -521,6 +521,7 @@ extern TFtype df_to_tf (DFtype);
> #endif /* ! FLOAT */
>
> #ifdef TMODES
> +extern DFtype __make_dp (fp_class_type, unsigned int, int, UDItype);
> extern TFtype __make_tp (fp_class_type, unsigned int, int, UTItype);
> #ifdef TFLOAT
> #if defined(L_tf_to_sf)
Ah ha! This also fixes two warnings in tp-bit.c
tp-bit.c:1588: warning: implicit declaration of function `__make_dp'
tp-bit.c:1588: warning: implicit declaration of function `__make_dp'
(There are still two other tp-bit.c warnings remaining.)
tp-bit.c:1392: warning: no previous prototype for `__fixunstfsi'
tp-bit.c:1392: warning: no previous prototype for `__fixunstfsi'
Right now we don't turn on -Werror for target files like libgcc2.c
etc, but I'm going to eventually turn it on to catch things like
this... :-)
Thanks for the quick fix!
--Kaveh
--
Kaveh R. Ghazi ghazi@caip.rutgers.edu
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Irix6 casting long double to double yields bogus results
2003-01-30 18:33 ` Kaveh R. Ghazi
@ 2003-02-03 13:29 ` Alexandre Oliva
0 siblings, 0 replies; 4+ messages in thread
From: Alexandre Oliva @ 2003-02-03 13:29 UTC (permalink / raw)
To: Kaveh R. Ghazi; +Cc: gcc-bugs, gcc-patches, gcc
On Jan 30, 2003, "Kaveh R. Ghazi" <ghazi@caip.rutgers.edu> wrote:
> (There are still two other tp-bit.c warnings remaining.)
> tp-bit.c:1392: warning: no previous prototype for `__fixunstfsi'
> tp-bit.c:1392: warning: no previous prototype for `__fixunstfsi'
This should fix them. Care to give them a round of testing?
--- fp-bit.c.~1.39.~ 2003-01-26 08:06:25.000000000 -0200
+++ fp-bit.c 2003-02-03 11:24:39.000000000 -0200
@@ -1377,7 +1381,7 @@ float_to_si (FLO_type arg_a)
#endif /* L_sf_to_si || L_df_to_si */
#if defined(L_sf_to_usi) || defined(L_df_to_usi) || defined(L_tf_to_usi)
-#if defined US_SOFTWARE_GOFAST || defined(L_tf_to_usi)
+#if defined US_SOFTWARE_GOFAST
/* While libgcc2.c defines its own __fixunssfsi and __fixunsdfsi routines,
we also define them for GOFAST because the ones in libgcc2.c have the
wrong names and I'd rather define these here and keep GOFAST CYG-LOC's
As for explaining what's going on: I was out of my mind when I forced
the function to be defined for L_tf_to_usi, GCC just doesn't use it.
The other variants are only used for GOFAST compatibility. We might
as well go ahead and take out L_tf_to_usi entirely from Makefile.in
and config/fp-bit.[ch], but there's no good reason to do so, and some
day GCC might be able to use float_to_unsigned anyway, so we might as
well leave it there.
--
Alexandre Oliva Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer aoliva@{redhat.com, gcc.gnu.org}
CS PhD student at IC-Unicamp oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist Professional serial bug killer
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2003-02-03 13:29 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-01-29 19:06 Irix6 casting long double to double yields bogus results Kaveh R. Ghazi
2003-01-30 9:05 ` Alexandre Oliva
2003-01-30 18:33 ` Kaveh R. Ghazi
2003-02-03 13:29 ` Alexandre Oliva
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 read-only IMAP folder(s) and NNTP newsgroup(s).