But in gcc targeting ultrasparc.
David Koppelman
koppel@ee.lsu.edu
Fri Jul 28 15:37:00 GMT 2000
I've found that code compiled by gcc 2.95 encounters a segmentation
fault or bus error when targeting the ultrasparc. Code to reproduce
the bug and a transcript of commands appears below.
__
/\ /\ /\
<> <> David M. Koppelman <>
<> koppel@ee.lsu.edu <> Electrical & Computer Eng. <>
<> +1 (225) 578-5482 <> Louisiana State University <>
<> http://www.ee.lsu.edu/koppel <> Baton Rouge, La 70803, USA <>
~~ ~~ ~~
#if 0
Program encountering bug in gcc targeting the ultrasparc.
Reported by David M. Koppelman, koppel@ee.lsu.edu
[sol] % uname -a
SunOS sol 5.6 Generic_105181-20 sun4u sparc SUNW,Ultra-Enterprise
[sol] % gcc -v
Reading specs from /opt/local/lib/gcc-lib/sparc-sun-solaris2.6/2.95.2/specs
gcc version 2.95.2 19991024 (release)
[sol] % gcc test.c -S -O3 -mcpu=ultrasparc -g
[sol] % gcc test.s -o test -mcpu=ultrasparc -g -lm
[sol] % test
Bus error
[sol] %
The resulting code uses std instructions with unaligned addresses when writing
values to pass to fprintf. Here is the offending assembler output:
.LLM22:
st %f2, [%fp-16]
ld [%fp-16], %g2
st %f3, [%sp+92]
mov %g2, %o5
std %f2, [%fp-16]
ldd [%fp-16], %g2
std %f2, [%sp+96]
mov %g2, %o3
mov %g3, %o4
std %f2, [%fp-184]
call fprintf, 0
std %f2, [%sp+108] <- Unaligned
.stabn 68,0,33,.LLM23-main
.LLM23:
#endif
#include <stdio.h>
#include <math.h>
int
main(argv, argc)
int argv;
char **argc;
{
double vals[] = { 0.29981156741642356663, 0.06534463297941150939,
0.08700884626263230268, 0.29481898613027235343,
0.40327876077409174349, 0.64313111626589508526,
0.87204040650558993179, 0.77195657231840326457,
0.84440588988184180826, 0.23206499454819179893, 0};
double results[] = { 1.356199986544775, 0.644148072499925, 0.286979564536114,
0.631265700663381, 0.560075902893138, 0.635453970629484,
0.846201478113202, 0.740605699133083, 1.302591557566638 };
double *rp = &results[0];
double *vp = &vals[0];
int err_count1 = 0;
int err_count2 = 0;
while ( *++vp != 0 )
{
double diff = atan2(vp[-1],vp[0]) - *rp++;
fprintf(stdout," %d %.16f, %f %f %d %f ",
err_count1,diff,diff,diff,err_count1,diff);
if( diff > 1e-15 ) err_count1++;
if( diff < -1e-15 ) err_count2++;
}
/* printf("%.15f, ", atan2(vp[-1],vp[0]) ); */
if( err_count1 + err_count2 ) printf("\nErrors found %d %d\n",
err_count1,err_count2);
return 0;
}
More information about the Gcc-bugs
mailing list