Regarding this change: http://en.wikipedia.org/w/index.php?title=Sequence_point&diff=next&oldid=15491632 I realise that when operators are overloaded th
| This article is rated Start-class on Wikipedia's content assessment scale. It is of interest to the following WikiProjects: | |||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||
Regarding this change: http://en.wikipedia.org/w/index.php?title=Sequence_point&diff=next&oldid=15491632 I realise that when operators are overloaded there are necessarily additional sequence points due to the extra function calls, but this applies to many of the other cases as well - in certain ways, C++ overloaded operators are a whole different ball game.
By definition when operators are overloaded, the ++ has to store its result first and make a copy of the old value, but for built-in types is the compiler not free to use any valid instruction order between sequence points as had been described? I admit I expanded on that section slightly when merging without consulting other sources though.
Of course, half of the point is that for any sensible expression, it doesn't matter what order these different values are updated... but it could make a difference if (for example) p happens to point to the location where its own value (or that of q) is stored, etc.
I'm relativly sure the following paragraph is incorrect.
Consider two functions f() and g(). In C and C++, the + operator is not a sequence point, and therefore in the expression f()+g() it is possible that either f() or g() will be executed first. The comma operator is a sequence point, and therefore in the code f(),g() the order of evaluation is defined (i.e., first f() is called, and then g() is called). The type and value of the whole expression are those of g(); the value of f() is discarded.
According to C99 5.1.2.3 Program execution Example, The function f() is guaranteed to be called before g(). Also on page 74, it also mentions that left associative operators of equal precedence will be executed in left to right order. The function f() will defiantly be called before g(). —Preceding unsigned comment added by 74.129.253.98 (talk) 04:14, 17 February 2009 (UTC)
109.192.0.81 (talk) —Preceding undated comment added 09:47, 4 December 2013 (UTC)
The article contradicts itself when it states that C++11's possibilities of sequencing include "indeterminately sequenced (one of the above but which is not defined)." The "one or the other" sounds like unspecified behavior, but the "not defined" sounds like undefined behavior. The difference is important because one "can result in time travel" according to Raymond Chen and the other can't. So which is it? --Damian Yerrick (talk) 15:03, 12 July 2015 (UTC)
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0145r3.pdf There's much less left in C++ that has unspecified sequencing — Preceding unsigned comment added by 67.163.56.218 (talk) 01:58, 5 March 2018 (UTC)
In Behavior up to C++03 there is stated:
To me, this sounds a little bit unclear. What does "%n is evaluated" means? Does it mean, the corresponding "&a" is evaluated? What is meant by "printing 42"? Conversion to two figures are done that are ready to be taken by underlying OS IO-routines? What is meant by "conversion"? That what is done by printf, when it encounters a "%..." code? Does that mean that every parameter given to function printf is evaluated (as usual in behalf of function calls) before any conversion takes place?
At the end: Is the order of evaluation of the function call parameter (i.e. '"foo %n %d"', '&a', and '42') in any way managed by sequence points?
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.