Thread View: gnu.gcc.bug
1 messages
1 total messages
Started by Peter Montgomery
Wed, 06 Jan 1993 23:06
Uninitialized address for temporary (SPARC, gcc 2.3.3)
Author: 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);
}
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads