delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2000/08/17/18:25:59

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT sources DOT redhat DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sources DOT redhat DOT com>
List-Help: <mailto:cygwin-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT sources DOT redhat DOT com
Delivered-To: mailing list cygwin AT sources DOT redhat DOT com
From: "Dan Haynes" <haynes AT anchorgaming DOT com>
To: "Brian J Ball" <bjball AT sep DOT com>, <cygwin AT sourceware DOT cygnus DOT com>
Subject: RE: B 20: Post incrementers in arrays as function arguments
Date: Thu, 17 Aug 2000 16:25:30 -0600
Message-ID: <00dd01c0089a$0ce03560$060da8c0@tired>
MIME-Version: 1.0
X-Priority: 3 (Normal)
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook 8.5, Build 4.71.2173.0
Importance: Normal
In-Reply-To: <NEBBINHAMKDDGPELHGEPAEBNCAAA.bjball@sep.com>
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.2106.4

Try using PC Lint to find the bugs in your code.

(hint - array[i++]=i depends on order of evaluation and is totally bogus C
code)

:-)

  Dan


> -----Original Message-----
> From: cygwin-owner AT sources DOT redhat DOT com
> [mailto:cygwin-owner AT sources DOT redhat DOT com]On Behalf Of Brian J Ball
> Sent: Thursday, August 17, 2000 4:07 PM
> To: cygwin AT sourceware DOT cygnus DOT com
> Subject: B 20: Post incrementers in arrays as function arguments
>
>
> This code has produced 3 different results on 4 systems.
> The second result was on the Cygwin B20 system
>
> #include <stdio.h>
> 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
>


--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019