Re: different behavour of printf() on dos and linux
Francis Glassborow wrote:
I think the confusion maybe with using the term 'sequence point' which
implies that the argument evaluations will be sequenced in the sense of
'in a specific order' Whereas you are focusing on 'Must be completely
evaluated' but in an arbitrary order.
I await the general hilarity which will ensue, when C++
experts try to explain the following behaviors:
int i = 1, j = i++, k = i++; // j == 1, k == 2
int i = 1, a[] = { i++, i++ }; // a[0] == 1, a[1] == 2
int i = 1, j; j = i++, i++; // j == 2
int i = 1; f(i++, i++); // Calls f(1, 2) or f(2, 1)
struct a {
int i;
a(int i) : i(i) { }
a operator++(int) { return a(i++); }
operator int() { return i; }
a operator,(a const &b) { return b; }
};
a i(1); int j; j = i++, i++; // j == 1 or j == 2
I'm particularly fond of how the user-defined comma operator
gets to confound the expectations of people accustomed to the
built-in one.
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]