Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!mit-eddie!bloom-beacon!tut.cis.ohio-state.edu!EAST.SUN.COM!lynch From: lynch@EAST.SUN.COM (Brendan Lynch - Sun East Coast Software) Newsgroups: gnu.gcc.bug Subject: Bug in gcc-1.35, sparc version Message-ID: <8905191848.AA11852@amandla.ESS.East.Sun.COM> Date: 19 May 89 18:48:16 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 93 I think I have found a bug in the builtin function calling sequence for the sparc in gcc-1.35. The following program: main() { int i; i = 3; printf("one is %d\n", i/3); } produces the following assembler code when compiled with "gcc -S": gcc_compiled.: .text LC0: .ascii "one is %d\12\0" .align 4 .global _main .proc 1 _main: !#PROLOGUE# 0 save %sp,-120,%sp !#PROLOGUE# 1 mov 3,%o2 st %o2,[%fp-20] call .div,0 nop mov %o0,%o1 sethi %hi(LC0),%o0 or %lo(LC0),%o0,%o0 mov %o1,%o1 call _printf,0 nop L1: ret restore and when run, produces the output: one is 0 The problem seems to be that the arguments to the builtin function ".div" are never put in the output registers, therefore the ".div" function returns 0. Using Version 1.34 of gcc, the following code is produced: gcc_compiled.: .text LC0: .ascii "one is %d\12\0" .align 4 .global _main .proc 1 _main: !#PROLOGUE# 0 save %sp,-120,%sp !#PROLOGUE# 1 mov 3,%o2 st %o2,[%fp-20] ld [%fp-20],%o0 mov 3,%o1 call .div,0 nop mov %o0,%o1 sethi %hi(LC0),%o0 or %lo(LC0),%o0,%o0 mov %o1,%o1 call _printf,0 nop L1: ret restore which produces the correct result. This seems only to be a problem for the sparc version; the 386 and 68020 versions seem to work fine. ---------------------------------------------------------------------- /\ \\ \ Brendan Lynch \ \\ / Sun Microsystems - Entry Systems Software / \/ / / 2 Federal Street, / / \//\ Billerica, Massachusetts 01821 \//\ / / / / /\ / Phone: (508) 671 0247 / \\ \ EMail: lynch@east.sun.com \ \\ ..!sun!east!lynch \/