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 X-Originating-IP: [212.54.79.234] From: "Jonas Jensen" To: "Brian J Ball" , References: 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: 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 AT sourceware DOT cygnus DOT com