Path: utzoo!utgpu!water!watmath!clyde!rutgers!ucla-cs!zen!ucbvax!decvax!decwrl!sun!pitstop!sundc!seismo!uunet!mcrware!jejones
From: jejones@mcrware.UUCP (James Jones)
Newsgroups: comp.lang.c
Subject: Re: `noalias' vs `register'
Summary: pathological control flow vs. register/noalias
Message-ID: <577@mcrware.UUCP>
Date: 17 Dec 87 09:44:16 GMT
References: <6829@brl-smoke.ARPA> <9753@mimsy.UUCP> <6830@brl-smoke.ARPA> <9796@mimsy.UUCP>
Organization: Microware Systems Corp., Des Moines, Ia.
Lines: 28

In article <9796@mimsy.UUCP>, chris@mimsy.UUCP (Chris Torek) writes:
> 	f() {
> 		register int r;
> 		...
> 		r = 1;
> 		g();
> 		if (r == 1) ...
> 
> Does the `if' succeed?  Yes, because there is no way for g() to
> alter `r'.

Ah, but g() need not be the culprit.  In the presence of setjmp()/longjmp(),
an arbitrary stretch of code in f() could have been executed.  (The particular
case you show looks safe, but in general, one could have

	r = 1;
	if (setjmp(jbuf) != 0) {
		/* code not involving r */
	}
	if (r == 1) {
		/* Shouldn't this always be true?  Not necessarily... */
	}
	r = 2;
	woof();

and somewhere in woof() or further down, longjmp() is called.)

	James Jones