From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <199610300057.QAA19660@hermes.astro.washington.edu> Date: Tue, 29 Oct 1996 16:57:20 -0800 From: Tom Quinn Subject: bug in xdr_double() on alpha The following code demonstrates a bug in xdr_double() on an alpha pc164 running RedHat 4.0 Linux. #include #include #include int main() { double d = 1.0; XDR xdrs; xdrstdio_create(&xdrs, stdout, XDR_ENCODE); xdr_double(&xdrs, &d); xdr_destroy(&xdrs); return 0; } When compiled with gcc version 2.7.2 and linked with libc-1.93, and run with a command: a.out > tst.out tst.out contains, according to od -t x4 tst.out: 0000000 00000000 00000001 It SHOULD contain: 0000000 3ff00000 00000000 The version string in the library is the following: GNU C Library alpha release version 1.93, by Roland McGrath et al. Compiled by GNU CC version 2.7.2. Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Report bugs to . Looking at sunrpc/xdr_float.c, it appears there are two problems: 1) The code assumes that sizeof(long) == sizeof(double)/2. For the alpha, sizeof(long) == sizeof(double). 2) Even if an int were used instead of a long, the second word of a double needs to be written before the first word. That is the statement: return (XDR_PUTLONG(xdrs, lp++) && XDR_PUTLONG(xdrs, lp)); needs to read something like: return (XDR_PUTLONG(xdrs, lp+1) && XDR_PUTLONG(xdrs, lp++)); A similar change needs to be made to the DECODE statement: return (XDR_GETLONG(xdrs, lp++) && XDR_GETLONG(xdrs, lp)); -- Tom Quinn Astronomy, University of Washington Internet: trq@astro.washington.edu Phone: 206-685-9009 -- To unsubscribe: mail -s unsubscribe axp-list-request@redhat.com < /dev/null