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 From: "Brian J Ball" To: Subject: B 20: Post incrementers in arrays as function arguments Date: Thu, 17 Aug 2000 17:06:53 -0500 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0) X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 Importance: Normal 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 -- Want to unsubscribe from this list? Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com