Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!olivea!mintaka!bloom-beacon!eru!hagbard!sunic!news.funet.fi!funic!santra!sauna.hut.fi!ado From: ado@sauna.hut.fi (Andre Dolenc) Newsgroups: comp.std.c Subject: order of evaluation & static variables Message-ID: <1990Oct30.075909.3848@santra.uucp> Date: 30 Oct 90 07:59:09 GMT Sender: news@santra.uucp (Cnews - USENET news system) Organization: Helsinki University of Technology, Finland Lines: 21 Consider the following code fragment: ----------- float *ff (p) float p; { static float gv; gv = p; return &gv; } main ... { printf ("= %f\n", *(ff((float)1.0)) + *(ff((float)2.0))); ... } ----------- Everyone *expects* the answer to be 3.0 (approx; change 'float' to 'int' if you do not like rounding errors in the example...). However, can a conforming implementation return (a) 1+1=2, or (b) 2+2=4 ?? (Yes, a well-known compiler returns (a) even without code opt.) Thanx in advance, ---------------------------------------------------------------------------- Andre' Dolenc Helsinki University of Technology Research Associate TKO, Otakaari 1A, Espoo Email (Internet): ado@sauna.hut.fi SF-02150 Finland ----------------------------------------------------------------------------