From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,18f5f858f5de71a,start X-Google-Attributes: gidfee84,public X-Google-ArrivalTime: 1994-10-20 14:51:27 PST Path: bga.com!news.sprintlink.net!howland.reston.ans.net!swrinde!news.uh.edu!phys6k From: phys6k@menudo.uh.edu (Yansong Chen ) Newsgroups: comp.unix.osf.osf1 Subject: Optimization bug on fork()? Date: 20 Oct 1994 21:30:09 GMT Organization: University of Houston Message-ID: <386nh1$231@masala.cc.uh.edu> NNTP-Posting-Host: menudo.uh.edu X-Newsreader: TIN [version 1.2 PL2] I have run the following program in AXP/OSF (axposf.stanford.edu), -------------------cut from here-------------------- #include #include main() { float x; int i; x = 1e3; for (i=0;i<1;i++) { fork(); printf("%f\n",x); } } ---------------end here------------------------------ The parent and child processes return same value of x if I do not turn on the optimization option when I compile it. But If I do optimization during compile, ( cc -O2 or -O3, gcc -O1 or -O2 ), the parent and child processes return different values. In my case, the parent return 1000, the child return 0. I run this program on axposf.stanford.edu. I don't know if this is the right newsgroup to post this question, but this case only happens in OSF/1. I have tried this program in many other different system, include Ultrix, Sun/OS, Solaris, Linux. It gives correct result in all of those systems, just gives wired result in OSF/1. So is that a bug in OSF/1? I do not subscribe this newsgroup, please send me e-mail if possible. Thank you for read this post.:_) -- yansong chen -- YChen@uh.edu