[net.bugs.4bsd] "struct" program mishandles computed GOTO's

root@ogcvax.UUCP (Bruce Jerrick) (04/11/84)

Subject: "struct" mishandles computed GOTO's
Index:	usr.bin/struct/* 4.2BSD

Description:
	"struct" will not properly handle a computed GOTO if
	the comma following the label list (...) isn't there.
	That comma is optional according to Fortran.
Repeat-By:
	Put the program between "----" below into file "bug.f".
	Verify that it will go through "struct" correctly as is
	by doing:

	    % struct bug.f

	(with or without "-s" flag; results are the same).
	Then change the computed GOTO from:

	      GOTO (10,20), I
	to:
	      GOTO (10,20) I
	
	and repeat "struct" command.  There will be messages
	about unreachable statements, and output will be
	incorrect.

------------------------------------------------------------
      PROGRAM BUG

C     "struct" will not properly handle the computed GOTO if
C       the comma following the label list (...) isn't there.
C     That comma is optional according to Fortran.

      I=2
      GOTO (10,20), I
   10 WRITE(6,100)
      GOTO 90
   20 WRITE(6,200)
      GOTO 90

   90 WRITE(6,900)
      STOP

  100 FORMAT(' STATEMENT 10')
  200 FORMAT(' STATEMENT 20')
  900 FORMAT(' STATEMENT 90')
      END
------------------------------------------------------------
-- 
Bruce Jerrick
Oregon Graduate Center