Path: utzoo!mnetor!tmsoft!torsqnt!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!meiko.co.uk!jim From: jim@meiko.co.uk Newsgroups: gnu.gcc.bug Subject: A bug (oh no) Message-ID: <18341.8911241652@subnode.meiko.co.uk> Date: 24 Nov 89 16:52:02 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 64 I have found a bug in gcc version 1.34 running on a SUN 4/110 under SunOS Release 4.0.3_EXPORT. The compiler was built using your standard sun4 installation scheme. The problem occurs when using the stdarg facilities, and appears to be related to the use of the (magic) "function" __builtin_saveregs. The problem is demonstrated by the following piece of code, which does not correctly save %o0 after calling nextLabel(). Note that when compiled with -g the code functions correctly, so looking with the debugger won't help ! int bug( int a, int b, int c, ...) { int label = nextLabel(); int * foo ; /* This is more or less what a call to va_start(foo,a) generates ! */ (__builtin_saveregs(), foo = &a); bah(label, foo); return label; } Compiled thus % gcc -S bug.c gives gcc_compiled.: .text .align 4 .global _bug .proc 1 _bug: !#PROLOGUE# 0 save %sp,-136,%sp !#PROLOGUE# 1 st %o0,[%fp-20] /* This is the store for label ! */ call ___builtin_saveregs,0 nop st %i0,[%fp+68] st %i1,[%fp+72] st %i2,[%fp+76] call _nextLabel,0 /* but here is the call ... */ nop add %fp,68,%o0 /* and here we throw away the result */ mov %o0,%o0 st %o0,[%fp-28] ld [%fp-20],%o0 ld [%fp-28],%o1 call _bah,0 nop ld [%fp-20],%i0 b L1 nop L1: ret restore Good luck. James Cownie p.s. Is anyone doing a gcc for the i860 ?