🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.micro.mac
Article #5995

Megamax bug?

#5995
From: Gregory Stein
Date: Mon, 09 Jun 1986 20:04
15 lines
996 bytes
Keywords:


I'm working in Megamax C, and I noticed a problem while I was in the
debugger.  It comes from these statements:

	for (i = ntables; i--; ) <statement>
	if (i == -1) <more statements>

I would expect this to get the value of i, decrement the stored value,
and then exit or execute the statement.  Rather, it tests the value
before it decrements, and the loop exits with i = 0.  Is this a bug
in the code generation, or is C supposed to do this?

	Greg
Technical Details
Message-ID: <1023@k.cs.cmu.edu>
Path: arc1-ca.pugleaf.net!utzoo!linus!philabs!cmcl2!seismo!rochester!pt.cs.cmu.edu!k.cs.cmu.edu!gjs

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!linus!philabs!cmcl2!seismo!rochester!pt.cs.cmu.edu!k.cs.cmu.edu!gjs
From: gjs@k.cs.cmu.edu (Gregory Stein)
Newsgroups: net.micro.mac
Subject: Megamax bug?
Message-ID: <1023@k.cs.cmu.edu>
Date: Mon, 9-Jun-86 16:04:55 EDT
Article-I.D.: k.1023
Posted: Mon Jun  9 16:04:55 1986
Date-Received: Wed, 11-Jun-86 00:54:53 EDT
Reply-To: gjs@k.cs.cmu.edu (Gregory Stein)
Distribution: net
Organization: Carnegie-Mellon University, CS/RI
Lines: 15