C optimizer
Barry Margolin
barmar at think.COM
Fri Feb 24 11:36:57 AEST 1989
In article <1028 at frog.UUCP> john at frog.UUCP (John Woods) writes:
>I think that if
> (getpid() != getpid())
>ever evaluated to 1, I would be severely astonished.
Well, how about
(pid = getpid(), (void) fork(), pid != getpid())
? It will evaluate to 0 in the parent process, 1 in the child
process.
Since fork() changes the value of getpid(), getpid() isn't pure. But
it would be wrong to make fork() always prevent common subexpression
elimination, since it doesn't modify any of the program's own
variables.
Barry Margolin
Thinking Machines Corp.
barmar at think.com
{uunet,harvard}!think!barmar
More information about the Comp.lang.c
mailing list