ぷらすぷらす

id:succeed:20080623 に関して。

C だと後置増分演算子の意味規則は次のように規定されている [6.5.2.4]。

後置++演算子の結果は、そのオペランドの値とする。結果を取り出した後、オペランドの値を増分する(すなわち、適切な型の値 1 をそれに加える。)。...

なんだか二度読み出すのが正統のような気すらするんだけど、どうなんでしょうか。

C++ でも似たような感じ [5.2.6]。

後置演算子 ++ を作用させて得る値は、演算子を作用させる前の演算対象の値とする。... 結果を得た後で、そのオブジェクトの値は、1 が加算された値に変更する。...

曖昧だが、原文も“After the result is noted, the value of the object is modified by adding 1 to it”らしい。

ついでに Java だとこう [15.4.2]。

... the value 1 is added to the value of the variable and the sum is stored back into the variable. ... The value of the postfix increment expression is the value of the variable before the new value is stored. ...

素直に受け取ると二度は読まない…のか? むぅ、読解に自信がない。