- To: egcs-bugs at cygnus dot com
- Subject: BUG: 2.95.1 19990809 (sparc-sun-solaris2.5.1)
- From: Fred Richardson <frichard at bbn dot com>
- Date: Mon, 16 Aug 1999 12:12:06 -0400
Hi-
I've come accross the following bug. I've seen the same bug in the
GCC 2.95 but not in EGCS 1.1.1
My system is:
%> fpversion
A SPARC-based CPU is available.
CPU's clock rate appears to be approximately 168.1 MHz.
Kernel says CPU's clock rate is 167.0 MHz.
Kernel says main memory's clock rate is 83.5 MHz.
Sun-4 floating-point controller version 0 found.
An UltraSPARC chip is available.
FPU's frequency appears to be approximately 177.4 MHz.
Use "-xtarget=ultra" code-generation option.
Hostid = 0x807C7BD9.
%>
I'm using the GNU assembler and linker from binutils-2.9.1.0.21.
The following code breaks if -mcpu=ultrasparc is specified:
%> cat bug2.c
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
typedef struct
{
int a_int;
float a_flt1;
char* a_str1;
char* a_str2;
float a_flt2;
} AStruct;
int main()
{
AStruct *dt = calloc(1, sizeof(AStruct));
dt->a_int = 0;
dt->a_flt1 = 756.430237;
dt->a_str1 = strdup("foo");
dt->a_str2 = strdup("bar");
dt->a_flt2 = 3.915038;
#ifdef TRIGGER_BUG
printf("leaf:%d, %f %s,%s entropy: %f\n",
dt->a_int,
dt->a_flt1,
dt->a_str1,
dt->a_str2,
dt->a_flt2);
#else
printf("leaf:%d, %f %s,%s entropy: ",
dt->a_int,
dt->a_flt1,
dt->a_str1,
dt->a_str2);
printf("%f\n", dt->a_flt2);
#endif
free(dt->a_str1);
free(dt->a_str2);
free(dt);
return (0);
}
%>
and the following conditions can trigger the bug or not:
%> gcc -mcpu=ultrasparc -DTRIGGER_BUG -o bug2 bug2.c && ./bug2
Bus error
%> gcc -mcpu=ultrasparc -o bug2 bug2.c && ./bug2
leaf:0, 756.430237 foo,bar entropy: 3.915038
%> gcc -DTRIGGER_BUG -o bug2 bug2.c && ./bug2
leaf:0, 756.430237 foo,bar entropy: 3.915038
%>