This is the mail archive of the
cygwin@sources.redhat.com
mailing list for the Cygwin project.
Re: Post incrementers in arrays as function arguments
- To: "Brian J Ball" <bjball at sep dot com>, <cygwin at sourceware dot cygnus dot com>
- Subject: Re: Post incrementers in arrays as function arguments
- From: "Jonas Jensen" <bones0_list at hotmail dot com>
- Date: Fri, 18 Aug 2000 20:14:01 +0200
- References: <NEBBINHAMKDDGPELHGEPAEBNCAAA.bjball@sep.com>
> 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