Article View: gnu.gcc.bug
Article #1595Uninitialized address for temporary (SPARC, gcc 2.3.3)
From: Peter Montgomery
Date: Wed, 06 Jan 1993 23:06
Date: Wed, 06 Jan 1993 23:06
72 lines
2496 bytes
2496 bytes
/*
Subject: Uninitialized address for temporary (SPARC, gcc 2.3.3)
Variables f1, f2, f3 contain successive results of
a floating point function. Since SPARC floating point
registers are not preserved by function calls,
gcc -O (version 2.3.3) moves f1 to %l4 and f2 to %l2.
Later, when f1, f2, and f3 are used in a computation,
address [%o3] is used to move f1 back to a floating
point register, but %o3 has not been initialized.
The problem occurs only if the program
has lots of local data, and a displacement over
12-bits might be required on the temporary.
Peter Montgomery
Department of Mathematics
Oregon State University
Corvallis, OR 97331-4605
pmontgom@math.orst.edu
Specifically, the generated code (SPARC, SunOS 4.1.1) contains
L6:
call _printf,0
mov %l2,%o1 itest (for printf)
call _drand48,0
add %l2,1,%l2 itest++
std %f0,[%fp-8]
ldd [%fp-8],%l4 %l4 = f1
call _drand48,0
nop
std %f0,[%fp-8]
ldd [%fp-8],%l0 %l0 = f2
call _drand48,0
nop
std %l4,[%o3] ***** %o3 undefined *****
ldd [%o3],%f4 Attempting to move f1 to %f4
sethi %hi(-5024),%o3
or %o3,%lo(-5024),%o3
add %o3,%fp,%o3
std %l0,[%o3]
ldd [%o3],%f6 %f6 = f2
faddd %f4,%f6,%f2 %f2 = f1 + f2
faddd %f2,%f0,%f0 %f0 = f1 + f2 + f3
std %f0,[%fp-8]
ld [%fp-4],%o2
ld [%fp-8],%o1
call _printf,0 Print f1 + f2 + f3
or %l3,%lo(LC1),%o0
*/
double drand48(); /* SUN random number generator */
/* #include <stdio.h> */
int main(int argc, char* argv[])
{
#if 1 /* Works if this is removed */
char unused[5000];
#endif
double f1, f2, f3;
int itest;
for (itest = 1; itest <= 10 ; itest++) {
printf("Iteration %d\n", itest);
f1 = drand48();
f2 = drand48();
f3 = drand48();
printf("Random sum: %6f\n", f1 + f2 + f3);
}
exit(0);
}
Technical Details
Message-ID:
<9301062306.AA11416@argus.MATH.ORST.EDU>Path:
arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!math.orst.edu!pmontgomShow Full Headers
Complete Article Headers
Newsgroups: gnu.gcc.bug Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!math.orst.edu!pmontgom From: pmontgom@math.orst.edu (Peter Montgomery) Subject: Uninitialized address for temporary (SPARC, gcc 2.3.3) Message-ID: <9301062306.AA11416@argus.MATH.ORST.EDU> Sender: gnulists@ai.mit.edu Organization: GNUs Not Usenet Distribution: gnu Date: Wed, 6 Jan 1993 23:06:40 GMT Approved: bug-gcc@prep.ai.mit.edu Lines: 73