🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: NET.v7bugs
Article #13

c2

#13
From: ucbvaxmark
Date: Sun, 18 May 1980 22:59
23 lines
860 bytes
>From mark Sat Apr 19 01:18:51 1980
To: v7bugs
Subject: bug in pdp-11 C optimizer
The following program demonstrates a bug in the V7 pdp-11 /lib/c2.
#include <stdio.h>
main () {
	int x;
	int t1;

	x = 0;
	x += 1;
	t1 = x != 1;
	printf("x=%d, t1=%d\n", x, t1);
	exit(0);
}
It should print 1, 0, but it prints 1, 1.  Seems that the optimizer has
correctly noticed that the value of x can be predicted at compile time
and hence the comparison can be precomputed, but it does the precomputation
wrong.  Changing the 2 assignments to x to "x = 1" works properly.

I don't have a fix for this, but dmr's (more recent than v7) version of
c2 seems to handle it correctly.
	Mark
Technical Details
Message-ID: <anews.Aucbvax.114>
Path: arc1-ca.pugleaf.net!utzoo!duke!vax135!ucbvax!mark

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!duke!vax135!ucbvax!mark
From: ucbvax!mark
Newsgroups: NET.v7bugs
Subject: c2
Date: Sun, 18 May 1980 22:59:08 +0000
Message-ID: <anews.Aucbvax.114>