Subject: sparc64 double casting bug?
To: None <tech-toolchain@netbsd.org>
From: Jarkko Hietaniemi <jhi@iki.fi>
List: port-sparc64
Date: 04/27/2002 21:26:48
Hi, while trying to get Perl-5.8.0-to-be running on NetBSD sparc64,
we ran into this oddity (this is a severely cut down version of a
test run by Perl's Configure script):

#include <stdio.h>
int main() {
    double d = 0;

#if 1
    if (d <= 0) { }
#endif
    d = (double)0;
    fprintf(stderr, "d = %g %lu\n", d, (unsigned long)d);
    exit(0);
}

The output in

% cc -v
Using builtin specs.
gcc version 2.95.3 20010315 (release) (NetBSD nb1)
% uname -a
NetBSD rfhs8036 1.5ZA NetBSD 1.5ZA (GENERIC) #0: Sun Dec 23 03:12:29 PST 2001     chs@ultra2:/build/obj/build/src/sys/arch/sparc64/compile/GENERIC sparc64
% 

is

d = 0 9223372036854775808

instead of

d = 0 0

The strange thing is that the bug seems to be somehow related to the
#if 1 comparison.  Change it to #if 0 and one gets the "d = 0 0".

-- 
$jhi++; # http://www.iki.fi/jhi/
        # There is this special biologist word we use for 'stable'.
        # It is 'dead'. -- Jack Cohen