[net.micro.amiga] Another Lattice C bug

fnf@unisoft.UUCP (Fred Fish) (02/28/86)

Lattice C is currently the only C compiler that I know of (I tested
3 others) that accepts the following code fragment:

	main ()
	{
		goto labl;
	labl:
	}

All others required that the labl: be attached to a statement, even
if only the null statement, as in:

	main ()
	{
		goto labl;
	labl:	;
	}

Note that this second usage is consistent with K&R page 63:

	"It (a label) can be attached to any *statement* (emphasis mine)
	 in the same function as the goto."

And on page 204:

	"Any statement may be preceded by label prefixes ..."

	"A null statement is useful to carry a label just before the }
	 of a compound statement ..."

Also, from "A C Reference Manual" by Harbison and Steele, page 199:

	"A label cannot appear by itself but must always be attached
	 to a statement.  If it is desired to place a label by itself, for
	 example at the end of a compound statement, it may be attached
	 to a null statement."

This construct, a label without a statement, showed up in the amiga3d
program recently posted to usenet's net.sources.

-Fred

===========================================================================
Fred Fish    UniSoft Systems Inc, 739 Allston Way, Berkeley, CA  94710  USA
{ucbvax,dual}!unisoft!fnf	(415) 644 1230 		TWX 11 910 366-2145
===========================================================================