Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!mnetor!uunet!seismo!husc6!cmcl2!phri!roy
From: roy@phri.UUCP (Roy Smith)
Newsgroups: comp.lang.c
Subject: re-using registers
Message-ID: <2803@phri.UUCP>
Date: Sun, 19-Jul-87 20:24:00 EDT
Article-I.D.: phri.2803
Posted: Sun Jul 19 20:24:00 1987
Date-Received: Mon, 20-Jul-87 03:36:12 EDT
Reply-To: roy@phri.UUCP (Roy Smith)
Organization: Public Health Research Institute, NYC, NY
Lines: 28


	Imagine the following (rather silly) function:

struct foo {struct foo *next;};
f(s, p)
char *s;
struct foo *p
{
	register char *rs;
	register struct foo *rp;

	for (rs = s; *rs != NULL; rs++);
	for (rp = p; rp->next != NULL; rp = rp->next);
}

	Are there any C compilers (or other languages, for that matter)
which are smart enough to realize that rs and rp could be put in the same
register?  In Fortran you would write this as "EQUIVALENCE (RS, RP)" and
the compiler wouldn't have to be smart at all, but that's cheating.

	Actually, I guess a really smart compiler might optimize the whole
function down to:

f() { return; }
-- 
Roy Smith, {allegra,cmcl2,philabs}!phri!roy
System Administrator, Public Health Research Institute
455 First Avenue, New York, NY 10016