bug in gcc 2.95.1 on SPARC Solaris
GOTOH Norifumi
gotoh@is.s.u-tokyo.ac.jp
Tue Aug 31 22:45:00 GMT 1999
Igor Schein <igor@txc.com> writes:
> On Fri, Aug 20, 1999 at 12:58:23PM +0900, GOTOH Norifumi wrote:
> > * Environments:
> >
> > architecture: SPARC, UltraSPARC I processor
> > os: Solaris 2.6
> > gcc version: both 2.95 & 2.95.1
> >
> >
> > * The complete input file (named test.c):
> > --------------------------------------------------------
> > #include <stdio.h>
> > int main(int argc, char** argv)
> > {
> > double d1, d2, d3, d4;
> > d1 = (double)argc;
> > d2 = d1*1.2;
> > d3 = d2*1.2;
> > d4 = d3*1.2;
> > return printd(d1, d2, d3, d4);
> > }
> >
> > int printd(double d1, double d2, double d3, double d4)
> > {
> > return printf("%f:%f:%f:%f\n", d1, d2, d3, d4);
> > }
> > --------------------------------------------------------
> >
> >
> > * The command arguments you gave GNU CC or GNU C++ to compile that
> > example and observe the bug. For example, did you use `-O'? To
> > guarantee you won't omit something important, list all the options.
> >
> > % gcc -O2 -o test test.c
> > % ./test
> > zsh: bus error (core dumped) ./test
>
> I can't reproduce this with 2.95.1. Why not send .ii and .s files?
> Which assembler are you using, Sun or GNU?
I am using Sun's as.
% gcc -print-prog-name=as
/usr/ccs/bin/as
The following assembler output has a line:
std %f2, [%sp+92]
which breaks 8-byte alignment to store doubles.
% gcc -o test.s -S -O2 test.c
[test.s]
.file "test.c"
gcc2_compiled.:
.section ".rodata"
.align 8
.LLC0:
.uaword 0x3ff33333 ! ~1.19999999999999995559e0
.uaword 0x33333333
.section ".text"
.align 32
.global main
.type main,#function
.proc 04
main:
!#PROLOGUE# 0
save %sp, -128, %sp
!#PROLOGUE# 1
sethi %hi(.LLC0), %g2
st %i0, [%fp-20]
ldd [%g2+%lo(.LLC0)], %f4
ld [%fp-20], %f6
fitod %f6, %f2
std %f2, [%fp-16]
ldd [%fp-16], %g2
fmuld %f2, %f4, %f2
mov %g2, %o0
mov %g3, %o1
std %f2, [%fp-16]
ldd [%fp-16], %o4
fmuld %f2, %f4, %f2
mov %o4, %o2
mov %o5, %o3
std %f2, [%fp-16]
ldd [%fp-16], %g2
fmuld %f2, %f4, %f2
mov %g2, %o4
mov %g3, %o5
call printd, 0
std %f2, [%sp+92]
ret
restore %g0, %o0, %o0
.LLfe1:
.size main,.LLfe1-main
.section ".rodata"
.align 8
.LLC1:
.asciz "%f:%f:%f:%f\n"
.section ".text"
.align 32
.global printd
.type printd,#function
.proc 04
printd:
!#PROLOGUE# 0
save %sp, -128, %sp
!#PROLOGUE# 1
sethi %hi(.LLC1), %o0
mov %i0, %o1
ld [%fp+92], %o2
mov %i4, %o5
or %o0, %lo(.LLC1), %o0
ld [%fp+96], %o3
mov %i3, %o4
st %i5, [%sp+92]
std %o2, [%sp+96]
mov %i1, %o2
call printf, 0
mov %i2, %o3
ret
restore %g0, %o0, %o0
.LLfe2:
.size printd,.LLfe2-printd
.ident "GCC: (GNU) 2.95.1 19990816 (release)"
% gcc -o test.ii -E -O2 test.c
[test.ii]
# 1 "test.c"
# 1 "/usr/include/stdio.h" 1 3
#pragma ident "@(#)stdio.h 1.49 97/05/09 SMI"
# 1 "/usr/include/sys/feature_tests.h" 1 3
#pragma ident "@(#)feature_tests.h 1.13 97/06/26 SMI"
# 17 "/usr/include/stdio.h" 2 3
# 1 "/usr/include/sys/va_list.h" 1 3
#pragma ident "@(#)va_list.h 1.6 96/01/26 SMI"
# 41 "/usr/include/sys/va_list.h" 3
typedef void *__va_list;
# 18 "/usr/include/stdio.h" 2 3
typedef unsigned int size_t;
typedef long long __longlong_t;
typedef long off_t;
typedef __longlong_t off64_t;
typedef long fpos_t;
typedef __longlong_t fpos64_t;
# 122 "/usr/include/stdio.h" 3
typedef struct
{
int _cnt;
unsigned char *_ptr;
unsigned char *_base;
unsigned char _flag;
unsigned char _file;
} FILE;
extern FILE __iob[20 ];
extern FILE *_lastbuf;
extern unsigned char *_bufendtab[];
extern unsigned char _sibuf[], _sobuf[];
# 222 "/usr/include/stdio.h" 3
extern int remove(const char *);
extern int rename(const char *, const char *);
extern FILE *tmpfile(void);
extern char *tmpnam(char *);
extern int fclose(FILE *);
extern int fflush(FILE *);
extern FILE *fopen(const char *, const char *);
extern FILE *freopen(const char *, const char *, FILE *);
extern void setbuf(FILE *, char *);
extern void setbuffer(FILE *, char *, size_t);
extern int setlinebuf(FILE *);
extern int setvbuf(FILE *, char *, int, size_t);
extern int fprintf(FILE *, const char *, ...);
extern int fscanf(FILE *, const char *, ...);
extern int printf(const char *, ...);
extern int scanf(const char *, ...);
extern int snprintf(char *, size_t, const char *, ...);
extern int sprintf(char *, const char *, ...);
extern int sscanf(const char *, const char *, ...);
extern int vfprintf(FILE *, const char *, __va_list);
extern int vprintf(const char *, __va_list);
extern int vsnprintf(char *, size_t, const char *, __va_list);
extern int vsprintf(char *, const char *, __va_list);
extern int fgetc(FILE *);
extern char *fgets(char *, int, FILE *);
extern int fputc(int, FILE *);
extern int fputs(const char *, FILE *);
extern int getc(FILE *);
extern int getchar(void);
extern char *gets(char *);
extern int putc(int, FILE *);
extern int putchar(int);
extern int puts(const char *);
extern int ungetc(int, FILE *);
extern size_t fread(void *, size_t, size_t, FILE *);
extern size_t fwrite(const void *, size_t, size_t, FILE *);
extern int fgetpos(FILE *, fpos_t *);
extern int fseek(FILE *, long, int);
extern int fsetpos(FILE *, const fpos_t *);
extern long ftell(FILE *);
extern void rewind(FILE *);
extern void clearerr(FILE *);
extern int feof(FILE *);
extern int ferror(FILE *);
extern void perror(const char *);
extern int __filbuf(FILE *);
extern int __flsbuf(int, FILE *);
extern FILE *fdopen(int, const char *);
extern char *ctermid(char *);
extern int fileno(FILE *);
# 319 "/usr/include/stdio.h" 3
extern FILE *popen(const char *, const char *);
extern char *cuserid(char *);
extern char *tempnam(const char *, const char *);
extern int getopt(int, char *const *, const char *);
extern int getsubopt(char **, char *const *, char **);
extern char *optarg;
extern int optind, opterr, optopt;
extern int getw(FILE *);
extern int putw(int, FILE *);
extern int pclose(FILE *);
extern int fseeko(FILE *, off_t, int);
extern off_t ftello(FILE *);
extern FILE *fopen64(const char *, const char *);
extern FILE *freopen64(const char *, const char *, FILE *);
extern FILE *tmpfile64(void);
extern int fgetpos64(FILE *, fpos64_t *);
extern int fsetpos64(FILE *, const fpos64_t *);
extern int fseeko64(FILE *, off64_t, int);
extern off64_t ftello64(FILE *);
# 467 "/usr/include/stdio.h" 3
# 515 "/usr/include/stdio.h" 3
# 1 "test.c" 2
int main(int argc, char** argv)
{
double d1, d2, d3, d4;
d1 = (double)argc;
d2 = d1*1.2;
d3 = d2*1.2;
d4 = d3*1.2;
return printd(d1, d2, d3, d4);
}
int printd(double d1, double d2, double d3, double d4)
{
return printf("%f:%f:%f:%f\n", d1, d2, d3, d4);
}
More information about the Gcc-bugs
mailing list