Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!SBCS.SUNYSB.EDU!stark
From: stark@SBCS.SUNYSB.EDU
Newsgroups: gnu.gcc.bug
Subject: Possible GCC Bug
Message-ID: <8909272011.AA14863@sbstark>
Date: 27 Sep 89 20:11:01 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 57

We are running GCC v. 1.35.0 on a Sun 3 running Sun OS 3.4.
I installed GCC using "tm-sun3.h" and "config/xm-m68k.h".

The problem is incorrect code output when compiling a switch statement
with a very long body.  The source was a y.tab.c generated by bison.
I can't send you the source because of the length, but a description of
the problem, and some of the generated code should be sufficient.
The problem is that GCC evidently fails to use full-word offsets when
constructing the dispatch table.  The relevant section of code generated
for the switch statement is as follows:

		.stabd 68,0,407
		movel d3,d0
		subql #1,d0
		cmpl #544,d0
		jhi L1520
	LI1519:
		movew pc@(L1519-LI1519-2:b,d0:l:2),d0
		jmp pc@(2,d0:w)
	L1519:
		.word L27-L1519
		.word L28-L1519
		.word L29-L1519
		.word L30-L1519

		

		.word L1507-L1519
		.word L1513-L1519
	L27:

		

	L1513:  

The branch was transferring to random locations when the initial value
in d3 got large enough.  We patched our "y.tab.s" by editing as follows:

	LI1519:
		movel pc@(L1519-LI1519-2:b,d0:l:4),d0
		jmp pc@(2,d0:l)
	L1519:
		.long L27-L1519
		.long L28-L1519

		

I wasn't sure if there was supposed to be a flag or pragma to handle
such a long switch correctly, but I suspect not, since a quick look
at the machine description file appears to show a hard-wired ".word"
in the macro to output the cases of a switch.

If I am missing something, I would really appreciate it if you would
tell me what it is.  Thanks.

						Gene Stark
						stark@sbcs.sunysb.edu