C optimizer

der Mouse mouse at mcgill-vision.UUCP
Wed Mar 15 20:16:51 AEST 1989


In article <453 at lakart.UUCP>, dg at lakart.UUCP (David Goodenough) writes:
> From article <36662 at think.UUCP>, by barmar at think.COM (Barry Margolin):
>> In article <1028 at frog.UUCP> john at frog.UUCP (John Woods) writes:
>>> (getpid() != getpid())  [should always be 1]
>> Well, how about
>> (pid = getpid(), (void) fork(), pid != getpid())
> True - but I don't see any references to fork() in Mr.Woods' posting.
> What he is stating is that _IN THE ABSENCE_ of fork() calls, getpid()
> had better return an unchanging value.

Sure - and in the absence of assignments, variables are constant and
can be optimized away.  The whole point of this was to find a pure
syscall, and a routine isn't pure if calling another routine can cause
it to change its return value for a given set of argument values.
Thus, fork()'s changing the return value of getpid() means that
getpid() can't be considered pure.

					der Mouse

			old: mcgill-vision!mouse
			new: mouse at larry.mcrcim.mcgill.edu



More information about the Comp.lang.c mailing list