🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.bug
Article #2530

optimizer bug

#2530
From: Eirik Fuller
Date: Tue, 11 Apr 1989 10:45
44 lines
1271 bytes
gcc 1.34 compiles the enclosed program incorrectly on a Tek 4316, when
invoked with -O.  Since the gcc configuration for the 4316 is similar
to the Sun 3 (68020/68881, m68k.md, tm-m68k.h), the same problem might
also occur on a Sun 3.

bug.c:

main()
{
  struct {char c; unsigned int d:16,i:11;} s;
  s.i = 9;
  exit ( ( s.i |= 7 ) == 15 ? 0 : 1);
}

bug.s:

#NO_APP
gcc_compiled.:
.text
	.even
.globl _main
_main:
	link a6,#-8
	moveq #9,d1
	bfins d1,a6@(-3){#0:#11}
	orb #0,a6@(-3)
	bfextu a6@(-3){#0:#11},d0
	moveq #15,d1
	cmpl d0,d1
	jne L2
	clrl d0
	jra L3
L2:
	moveq #1,d0
L3:
	movel d0,sp@-
	jbsr _exit
	unlk a6
	rts

With optimization on, the program exits with status 1; d0 remains at
9; there is no sign of the 7.  With optimization off, the program
exits with status 0; in this case the 7 is also visible in the
assembly output.
Technical Details
Message-ID: <8904111045.AA08160@elf.Stanford.EDU>
Path: arc1-ca.pugleaf.net!utzoo!telly!attcan!dptcdc!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ELF.STANFORD.EDU!eirik

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!telly!attcan!dptcdc!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ELF.STANFORD.EDU!eirik
From: eirik@ELF.STANFORD.EDU (Eirik Fuller)
Newsgroups: gnu.gcc.bug
Subject: optimizer bug
Message-ID: <8904111045.AA08160@elf.Stanford.EDU>
Date: 11 Apr 89 10:45:53 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 44