Path: utzoo!telly!ddsw1!lll-winken!killer!mit-eddie!bloom-beacon!tut.cis.ohio-state.edu!moose.cita.toronto.edu!trq From: trq@moose.cita.toronto.edu (Tom Quinn) Newsgroups: gnu.gcc.bug Subject: bug in sparc gcc 1.28 Message-ID: <8809221510.AA24703@moose.cita.toronto.edu> Date: 22 Sep 88 15:10:15 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 86 The following code points out an alignment bug in sparc gcc version 1.28. The static structure zero_time is given an alignment of 4, but an "ldd" instruction, which requires an alignment of 8, is used to access it, giving a Bus Error if you are unlucky. A quick fix would be in output-sparc.c:output_move_double(): Delete the code following the comment about knowing the structure is double aligned. Tom Quinn Canadian Institute for Theoretical Astrophysics trq@moose.cita.toronto.edu SOON TO BE trq@moose.cita.utoronto.ca UUCP - decvax!utgpu!moose!trq BITNET - quinn@utorphys.bitnet ARPA - trq%moose.cita.toronto.edu@relay.cs.net The compile: gcc -S -g -v -sun4 -c NextEvent.c gcc version 1.28 /usr/local/lib/gcc-cpp -v -undef -D__GNU__ -D__GNUC__ -Dsparc -Dsun -Dunix NextEvent.c /tmp/cca14379.cpp GNU CPP version 1.28 /usr/local/lib/gcc-cc1 /tmp/cca14379.cpp -quiet -dumpbase NextEvent.c -g -version -o NextEvent.s GNU C version 1.28 (sparc) compiled by GNU C version 1.28. Relavent assembler output: .data .align 4 <<< This should be 8 _zero_time.0: .word 0 .word 0 . . . .stabn 68,0,45,LM10 LM10: set _zero_time.0,%l3 ldd [%l3],%o2 <<< Or this should be two instructions std %o2,[%fp-72] The code: typedef char Boolean; struct timeval { long tv_sec; long tv_usec; }; struct timezone { int tz_minuteswest; int tz_dsttime; }; typedef long xfd_mask; typedef struct xfd_set { xfd_mask fds_bits[(((256 )+(( (sizeof(xfd_mask) * 8))-1))/( (sizeof(xfd_mask) * 8))) ]; } xfd_set; Boolean _XtwaitForSomething(ignoreTimers, ignoreInputs, block, howlong) Boolean ignoreTimers; Boolean ignoreInputs; Boolean block; unsigned long *howlong; { struct timezone cur_timezone; struct timeval cur_time; struct timeval start_time; struct timeval wait_time; struct timeval new_time; struct timeval time_spent; struct timeval max_wait_time; static struct timeval zero_time = { 0 , 0}; register struct timeval *wait_time_ptr; xfd_set rmaskfd, wmaskfd, emaskfd; static xfd_set zero = { 0 }; register int nfound, i; Boolean ret; if(block) { (void) gettimeofday (&cur_time, &cur_timezone); start_time = cur_time; if(howlong == 0 ) { wait_time_ptr = 0; } else { max_wait_time.tv_sec = *howlong/1000; max_wait_time.tv_usec = (*howlong %1000)*1000; wait_time_ptr = &max_wait_time; } } else { max_wait_time = zero_time; wait_time_ptr = &max_wait_time; } return ret; }