🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.atari.st
Article #26973

Re: Megamax bug or crappy C ?

#26973
From: Burris
Date: Fri, 22 May 1987 13:05
39 lines
1424 bytes
In article <756@klipper.cs.vu.nl>, tulp@cs.vu.nl (Eduard Tulp) writes:

> Try this piece of code with the Megamax C compiler.  I am not sure whether 
> this  is a bug...

> 
> main()
> 
> {
 	.
	.
	.

> 
>   while (i > 0)
>         array[i - 1] = array[i--] - 1;              /* Trouble here.  */
	.
	.
	.
>   while (i < 6)
>         array[i + 1] = array[i++] + 1;            /* And trouble here. */
	.
	.
	.
> }


Function calls, nested assignments, and increment and decrement operators cause
"side effects"...

...One unhappy situation is typified by the statement

	a[ i ] = i++;

...When side effects (assignment to actual variables) takes place is left to
the discretion of the compiler...

The moral of this discussion is that writing code which depends on order
of evaluation is a bad programming practice in any language...
Technical Details
Message-ID: <2084@ihuxz.ATT.COM>
Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!rutgers!ames!lll-tis!ptsfa!ihnp4!ihuxz!burris
References: <756@klipper.cs.vu.nl>

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!rutgers!ames!lll-tis!ptsfa!ihnp4!ihuxz!burris
From: burris@ihuxz.ATT.COM (Burris)
Newsgroups: comp.sys.atari.st
Subject: Re: Megamax bug or crappy C ?
Message-ID: <2084@ihuxz.ATT.COM>
Date: Fri, 22-May-87 09:05:04 EDT
Article-I.D.: ihuxz.2084
Posted: Fri May 22 09:05:04 1987
Date-Received: Sat, 23-May-87 16:32:04 EDT
References: <756@klipper.cs.vu.nl>
Organization: AT&T Bell Laboratories - Naperville, Illinois
Lines: 39
Summary: Here's what K & R say.