🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.micro.mac
Article #7426

TML Pascal 2.0 Compiler Bug

#7426
From: #BRUCE R. FOWLER
Date: Tue, 30 Sep 1986 16:56
40 lines
1899 bytes
	< WHERE'S MY CAN OF BUG SPRAY ??? ... > 

I got my brandy-new TML Pascal Version 2.0, August 1986, and
proceeded to break it with my very first program.  Such is life.

It seems that the compiler is generating bogus code when a function
that returns an enumerated value is referenced in a case statement:
		...
	type	fruit = ( apple, pear, banana, orange, kumquat );
		...
	function salad_part : fruit;
	    begin
		...
	    end;
	begin	{ main }
		...
	    case salad_part of
		apple:	peelandcore(0.5*servings);
		...
		{ etc. }

When the program executes the case statement, it branches off to
never-never land (even with range checking enabled).  I haven't
studied the generated code in detail to determine the exact cause
of the problem, but there is an "AND A1,D7" instruction in the case
branch calculation that doesn't make much sense at first glance.
After spending a couple hours tracking this down, I reproduced it
with a simplified example, so I suspect it will occur whenever the
above construction is used.  The work-around is to assign the
function result to an intermediate variable and then use that in
the case.

I plan to write Tom Leonard to report this problem, but in the
meantime, maybe this posting will save somebody a hassle.

						Bruce Fowler
						{ihnp4}!ho2cad!brf
^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v
    "The Twilight Zone - Love it or Leave it..."
Technical Details
Message-ID: <423@ho2cad.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!cbatt!ihnp4!houxm!ho2cad!brf

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!cbatt!ihnp4!houxm!ho2cad!brf
From: brf@ho2cad.UUCP (#BRUCE R. FOWLER )
Newsgroups: net.micro.mac
Subject: TML Pascal 2.0 Compiler Bug
Message-ID: <423@ho2cad.UUCP>
Date: Tue, 30-Sep-86 12:56:26 EDT
Article-I.D.: ho2cad.423
Posted: Tue Sep 30 12:56:26 1986
Date-Received: Wed, 1-Oct-86 05:33:30 EDT
Organization: AT&T Bell Laboratories, Holmdel
Lines: 40