develooper Front page | perl.perl5.porters | Postings from September 2003

5.8.1 warnings when long double == double

Thread Next
From:
Andy Dougherty
Date:
September 10, 2003 09:03
Subject:
5.8.1 warnings when long double == double
Message ID:
Pine.SOL.4.53.0309101203010.10837@maxwell.phys.lafayette.edu
Here's a curious corner Configure case:

If you Configure perl-5.8.x with -Duselongdouble, but
sizeof(long double)== sizeof(double), then Configure will still set
NV to 'long double', but perl.h will unset USE_LONG_DOUBLE due to
the following logic (lines 1177-79):

    #  if !(defined(HAS_LONG_DOUBLE) && (LONG_DOUBLESIZE > DOUBLESIZE))
    #     undef USE_LONG_DOUBLE /* Ouch! */
    #  endif

The end result is that we do use long double (since NV is 'long double')
but the sections of code that check USE_LONG_DOUBLE get skipped.
This is mostly harmless since the two types are, in fact, probably
exactly the same.  For gcc version 3.3.1 20030626 (Debian prerelease)
on sparc64, I did get these warnings:

    pp_ctl.c: In function `Perl_pp_formline':
    pp_ctl.c:712: warning: double format, NV arg (arg 5)
    pp_ctl.c:715: warning: double format, NV arg (arg 4)
    pp_ctl.c:749: warning: double format, NV arg (arg 5)
    pp_ctl.c:752: warning: double format, NV arg (arg 4)

    pp_pack.c: In function `S_unpack_rec':
    pp_pack.c:1662: warning: passing arg 2 of `modf' from incompatible pointer type

    POSIX.xs: In function `XS_POSIX_modf':
    POSIX.xs:1180: warning: passing arg 2 of `modf' from incompatible pointer type

These are harmless since 'long double' and 'double' are, in fact quite
compatible.

I'm *not* going to propose a Configure change at this point for 5.8.x,
but I think that for 5.9.x, perhaps the perl.h logic ought to be either
eliminated (and the various sections in pp_pack, sv.c, etc. changed to
handle this case) or the logic should be moved earlier into Configure,
and Configure should simply refuse to try to build with long double if
it's not really any different from plain double.

I *am* going to propose the following trivial patch, with the
understanding that it probably shouldn't be applied unless Jarkko's got
to re-gen Configure anyway.

--- perl-5.8.x/Configure	2003-08-25 13:08:38.000000000 -0400
+++ perl-5.8.x-andy/Configure	2003-09-10 11:28:23.000000000 -0400
@@ -5572,6 +5572,8 @@
 	fi
 	if $test "X$doublesize" = "X$longdblsize"; then
 		echo "(That isn't any different from an ordinary double.)"
+		echo "I'll keep your setting anyway, but you may see some"
+		echo "harmless compilation warnings."
 	fi
 	;;
 esac

-- 
    Andy Dougherty		doughera@lafayette.edu

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About