Mailing-List: contact cygwin-help@sourceware.cygnus.com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe@sources.redhat.com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin@sources.redhat.com>
List-Help: <mailto:cygwin-help@sources.redhat.com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner@sources.redhat.com
Delivered-To: mailing list cygwin@sources.redhat.com
X-Originating-IP: [212.54.79.234]
From: "Jonas Jensen" <bones0_list@hotmail.com>
To: "Brian J Ball" <bjball@sep.com>, <cygwin@sourceware.cygnus.com>
References: <NEBBINHAMKDDGPELHGEPAEBNCAAA.bjball@sep.com>
Subject: Re: Post incrementers in arrays as function arguments
Date: Fri, 18 Aug 2000 20:14:01 +0200
MIME-Version: 1.0
Content-Type: text/plain;	charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 5.50.4133.2400
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400
Message-ID: <OE30vpvDtDJd5IghQYY00000a5d@hotmail.com>
X-OriginalArrivalTime: 18 Aug 2000 22:06:10.0502 (UTC) FILETIME=[8426CE60:01C00960]

> This code has produced 3 different results on 4 systems.
> The second result was on the Cygwin B20 system
> [snip]
>    /*  This use of var++ in a function call is
> unpredictable */
>    print_array(array[i++],array[i++],array[i++]);
> }
> [snip]
> However, this works on some platforms and could become an error in porting
> software.

This is semi-documented behavior. Check out the infopage for gcc, this is
from the section "non-bugs":

>>>>>>>>>>>>>>>>>>>>>>>>>
* Making side effects happen in the same order as in some other
  compiler.

  It is never safe to depend on the order of evaluation of side
  effects.  For example, a function call like this may very well
  behave differently from one compiler to another:

       void func (int, int);

       int i = 2;
       func (i++, i++);

  There is no guarantee (in either the C or the C++ standard language
  definitions) that the increments will be evaluated in any
  particular order.  Either increment might happen first.  `func'
  might get the arguments `2, 3', or it might get `3, 2', or even
  `2, 2'.
<<<<<<<<<<<<<<<<<<<<<<<<<

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

