Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ncar!ames!think!barmar From: barmar@think.COM (Barry Margolin) Newsgroups: comp.lang.c Subject: Re: C optimizer Keywords: C pure function optimization Message-ID: <36662@think.UUCP> Date: 24 Feb 89 01:36:57 GMT References: <515@larry.UUCP> <9648@smoke.BRL.MIL> <36034@bbn.COM> <3121@ficc.uu.net> <1028@frog.UUCP> Sender: news@think.UUCP Reply-To: barmar@kulla.think.com.UUCP (Barry Margolin) Organization: Thinking Machines Corporation, Cambridge, MA Lines: 22 In article <1028@frog.UUCP> john@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@think.com {uunet,harvard}!think!barmar