I found a problem because the FP emulation of long doubles in the m68k port doesn't treat -0.0 correctly. A cast from a long double -0.0 to a double results in a double with the value -2.0.
The relevant function is __truncxfdf2 in gcc/config/m68k/fpgnulib.c. There are two issues here. First of all the short-cut test for zero only tested for +0.0, not -0.0. However that by itself shouldn't have shown up a problem as the more lengthy code underneath should have still come up with the right answer. The problem is that it doesn't treat a long double exponent of 0 as special. Without this fixed, subnormal numbers continue to be broken when converted to doubles. I believe this is the correct fix, but I'm not sure: --- fpgnulib.c~ Mon Jan 12 03:55:42 2004 +++ fpgnulib.c Sun Feb 27 04:05:13 2005 @@ -315,8 +315,14 @@ ldl.ld = ld; /*printf ("xfdf in: %s\n", dumpxf (ld));*/ - if (!ldl.l.upper && !ldl.l.middle && !ldl.l.lower) - return 0; + /* Match +/- 0 and subnormals, which get flushed to 0 */ + if ( EXPX(ldl) == 0 ) + { + /* Preserve sign */ + dl.l.upper = SIGNX (ldl); + dl.l.lower = 0; + return dl.d; + } exp = EXPX (ldl) - EXCESSX + EXCESSD; /* ??? quick and dirty: keep `exp' sane */ In the above case, both +/- 0 and subnormals cause a correctly signed double 0.0 to be returned. Is this the right fix? In case it is: 2005-02-27 Jonathan Larmour <[EMAIL PROTECTED]> * config/m68k/fpgnulib.c (__truncxfdf2): Match subnormals as well as -0.0 in special case test, and preserve sign. -- Summary: [m68k] long double -> double cast fails with -0.0 Product: gcc Version: 3.4.3 Status: UNCONFIRMED Severity: minor Priority: P3 Component: target AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: jifl-bugzilla at jifvik dot org CC: gcc-bugs at gcc dot gnu dot org GCC build triplet: i686-pc-linux-gnu GCC host triplet: i686-pc-linux-gnu GCC target triplet: m68k-elf http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20227