Talk:Sequence point
| This article is of interest to the following WikiProjects: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Links from this article with broken #section links (check): |
Untitled [edit]
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.
Problem [edit]
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)
- That is incorrect. Nowhere in C and/or C++ language specifications it says that built-in left-associative operators are executed in left-to-right order. There's no such example in 5.1.2.3 and there's nothing even remotely relevant on page 74 of C99. Please, clarify where you are getting this from.
- Why do we care where he gets it from? As you say, it's incorrect. — DAGwyn — Preceding unsigned comment added by 158.12.36.83 (talk) 21:42, 20 June 2011 (UTC)
- Unassessed C/C++ articles
- Unknown-importance C/C++ articles
- WikiProject C/C++ articles
- Stub-Class Java articles
- Low-importance Java articles
- WikiProject Java articles
- Unassessed Computing articles
- Unknown-importance Computing articles
- Unassessed software articles
- Unknown-importance software articles
- All Software articles
- Unassessed software articles of Unknown-importance
- All Computing articles
- Unassessed Computer science articles
- Unknown-importance Computer science articles
- WikiProject Computer science articles