Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT sources DOT redhat DOT com Delivered-To: mailing list cygwin AT sources DOT redhat DOT com Message-Id: <4.3.1.2.20000817181457.00b2f9e8@pop.ma.ultranet.com> X-Sender: lhall AT pop DOT ma DOT ultranet DOT com X-Mailer: QUALCOMM Windows Eudora Version 4.3.1 Date: Thu, 17 Aug 2000 18:16:10 -0400 To: "Brian J Ball" , "cygwin AT sourceware DOT cygnus DOT com" From: "Larry Hall (RFK Partners, Inc)" Subject: Re: B 20: Post incrementers in arrays as function arguments In-Reply-To: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" At 06:06 PM 8/17/2000, Brian J Ball wrote: >This code has produced 3 different results on 4 systems. >The second result was on the Cygwin B20 system > >#include >int i; >void do_increment(int array[]){ > for(i;i<10;){ > array[i++]=i; > } >} >void print_array(int a, int b, int c){ > printf("%i\t%i\t%i\n",a,b,c); >} > >main(void){ > int array[10]; > i=0; > do_increment(array); > i=0; > /* This use of var++ in a function call is > unpredictable */ > print_array(array[i++],array[i++],array[i++]); >} > >B20 (gcc 2.91.57) on NT 4 output: >2 1 0 > >The only workarround is to know how your system behaves or define temp >variables. a similar function call was used by a client, and our tests >showed it failing, since our tester was using VStudio. The client was using >the Tasking complier. >However, this works on some platforms and could become an error in porting >software. As to patching... I haven't tried the latest gcc, and I'm not >versed in compiler theory. > >I was not able to find information about this on GNATS or in the cygnus >mailing list archives. > >gcc 2.8.0 on solaris (expected answer) >0 1 2 > >Microsoft Visual Studio 6 >0 0 0 > >Our fourth platform was a Tasking compiler for a Seimens micro >It behaved as we expected (no stdio though). > >-- >Brian Ball >Software Engineer - SEP >mailto:bjball AT sep DOT com And what's the reason that you expect that the results would be predictable here? Larry Hall lhall AT rfk DOT com RFK Partners, Inc. http://www.rfk.com 118 Washington Street (508) 893-9779 - RFK Office Holliston, MA 01746 (508) 893-9889 - FAX -- Want to unsubscribe from this list? Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com