# Order of evaluation

< c‎ | language

C
 言語 ヘッダ 型サポート プログラムユーティリティ 可変長引数サポート エラー処理 動的メモリ管理 日付と時間のユーティリティ 文字列ライブラリ アルゴリズム 数値演算 入出力サポート ローカライゼーションサポート アトミック操作 (C11) スレッドサポート (C11) 技術仕様書

C言語
 ASCII コード表 基本概念 キーワード プリプロセッサ 文 式 初期化 宣言 関数 その他 C の歴史 技術仕様書

Original:
Order of evaluation of the operands of any C operator, including the order of evaluation of function arguments in a function-call expression, and the order of evaluation of the subexpressions within any expression is unspecified (except where noted below). The compiler will evaluate them in any order, and may choose another order when the same expression is evaluated again.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Original:
There is no concept of left-to-right or right-to-left evaluation in C, which is not to be confused with left-to-right and right-to-left associativity of operators: the expression a + b + c is parsed as (a + b) + c due to left-to-right associativity of operator+, but the subexpression c may be evaluated first (or last, or at the same time as a or b) at run time.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

## 目次

### [編集]定義

#### [編集]評価

それぞれの表現あるいはその部分式（オプションですどちらも）のためにコンパイラによって実行評価の2種類があります
Original:
There are two kinds of evaluations performed by the compiler for each expression or subexpression (both of which are optional):
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
• の値の計算：式によって返される値の計算。これは、オブジェクト（左辺値評価）、または以前のオブジェクト（右辺の評価）に割り当てられた値を読み出すの同一性の決定を伴うことがあります
Original:
value computation: calculation of the value that is returned by the expression. This may involve determination of the identity of the object (lvalue evaluation) or reading the value previously assigned to an object (rvalue evaluation)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
• 副作用：、ファイルを変更して、浮動小数点環境（サポートされている場合）を変更する、またはその関数を呼び出して、オブジェクトに揮発性glvalue、変更（書き込み）によって指定されたオブジェクトへのアクセス権（読み取りまたは書き込み）これらの操作のいずれかを行います.
Original:
side effect: access (read or write) to an object designated by a volatile glvalue, modification (writing) to an object, modifying a file, modifying the floating-point environment (if supported), or calling a function that does any of those operations.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Original:
If no side effects are produced by an expression and the compiler can determine that the value is not used, the expression is not evaluated.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

#### [編集]オーダー

"シークエンス·前"とは、同じスレッド内での評価との間に非対称、他動詞、ペアワイズの関係（原子の種類とメモリバリアが関与している場合、それは、スレッド間で延長することができる）です.
Original:
"sequenced-before" is an asymmetric, transitive, pair-wise relationship between evaluations within the same thread (it may extend across threads if atomic types and memory barriers are involved).
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
• シーケンスポイントが部分式E1とE2の間に存在している場合は、E1の両方の値の計算と副作用は、すべての値の計算とサイドE2のエフェクトの前に順序付けされます
Original:
If a sequence point is present between the subexpressions E1 and E2, then both value computation and side effects of E1 are sequenced before every value computation and side effect of E2
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
• 評価Bの前にシーケンスされた場合は評価Bの評価が開始される前に、その後の評価は完了します。 (C11およびそれ以降)
Original:
If evaluation A is sequenced before evaluation B, then evaluation of A will be complete before evaluation of B begins. (C11およびそれ以降)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
• BとBが前に配列決定される前に、配列決定されていない場合の評価を開始する前に、Bの評価が完了します。 (C11およびそれ以降)
Original:
If A is not sequenced before B and B is sequenced before A, then evaluation of B will be complete before evaluation of A begins. (C11およびそれ以降)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
• BとBが前に配列決定されていない前に、配列決定されていない場合は、2つの可能性があります：(C11およびそれ以降)
Original:
If A is not sequenced before B and B is not sequenced before A, then two possibilities exist: (C11およびそれ以降)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
• AとBの*評価は、非配列されています：彼らは（単一の実行スレッド内では、コンパイラはAとBを構成するCPU命令をインターリーブすることがあります）どのような順序で実行されてもよいと重なるかもしれません
Original:
* evaluations of A and B are unsequenced: they may be performed in any order and may overlap (within a single thread of execution, the compiler may interleave the CPU instructions that comprise A and B)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
• AとBの*評価がindeterminably順です：彼らはどのような順序で実行されてもよいが重複してはなりません：どちらかBの前に完全なものとなり、Aのいずれかの順序が同じ次回反対かもしれない前に、Bが完全なものとなる式が評価され.
Original:
* evaluations of A and B are indeterminably-sequenced: they may be performed in any order but may not overlap: either A will be complete before B, or B will be complete before A. The order may be the opposite the next time the same expression is evaluated.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

### [編集]ルール

1)
すべての関数の引数の評価後と関数指定の、実際の関数呼び出しの前にシーケンスポイントがあります.
Original:
There is a sequence point after the evaluation of all function arguments and of the function designator, and before the actual function call.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
2)

Original:
The value computations (but not the side-effects) of the operands to any operator are sequenced before the value computation of the result of the operator (but not its side-effects). (C11およびそれ以降)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
3)

Original:
There is a sequence point after evaluation of the first (left) operand and before evaluation of the second (right) operand of the following binary operators: && (logical AND), || (logical OR), and , (comma).
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
4)

Original:
There is a sequence point after evaluation of the first (left) operand and before evaluation of the second or third operand (whichever is evaluated) of the conditional operator ?:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
5)

Original:
The side effect (modification of the left argument) of the direct assignment operator and of all compound assignment operators is sequenced after the value computation (but not the side effects) of both left and right arguments. (C11およびそれ以降)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
6)
ポストインクリメントとpostdecrement演算子の値の計算は、その副作用の前に配列決定される。 (C11およびそれ以降)
Original:
The value computation of the postincrement and postdecrement operators is sequenced before its side-effect. (C11およびそれ以降)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
7)

Original:
There is a sequence point at the end of a full declarator. (C99およびそれ以降)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
8)

Original:
There is a sequence point after the evaluation of a full expression (an expression that is not a subexpression: typically something that ends with a semicolon or a controlling statement of if/switch/while/do) and before the next full expression.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
9)
シーケンスポイントは、ライブラリ関数の戻り値の直前にあります。 (C99およびそれ以降)
Original:
There is a sequence point immediately before the return of a library function. (C99およびそれ以降)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
10)
シーケンスポイントは、フォーマットされたI / Oの各変換指定子に関連付けられたアクションの後にがある(C99およびそれ以降)
Original:
There is a sequence point after the action associated with each conversion specifier in formatted I/O. (C99およびそれ以降)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
11)
qsortbsearch、ならびに比較関数への呼び出しとqsort(C99およびそれ以降)によって作られ、関連付けられたオブジェクトの移動の間に、ライブラリ関数によって行われた比較関数を呼び出すたびに、前後とすぐにシーケンスポイントがあります
Original:
There are sequence points before and immediately after each call to a comparison function made by the library functions qsort and bsearch, as well as between any call to the comparison function and the movement of the associated objects made by qsort (C99およびそれ以降)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
12)

Original:
A function call that is not sequenced before or sequenced after another function call is indeterminately sequenced (CPU instructions that constitute different function calls cannot be interleaved, even if the functions are inlined) (C11およびそれ以降)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
13)

Original:
In initialization list expressions, all evaluations are indeterminately sequenced (C11およびそれ以降)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
14)

Original:
With respect to an indeterminately-sequenced function call, the operation of compound assignment operators, and both prefix and postfix forms of increment and decrement operators are single evaluations. (C11およびそれ以降)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

### [編集]未定義の動作

1)
スカラオブジェクトに副作用が同じスカラオブジェクトの別の副作用に対する相対非配列されている場合、動作は未定義です.
Original:
If a side effect on a scalar object is unsequenced relative to another side effect on the same scalar object, the behavior is undefined.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

i = ++i + i++; // undefined behavior
i = i++ + 1; // undefined behavior
f(++i, ++i); // undefined behavior
f(i = -1, i = -1); // undefined behavior

2)
スカラオブジェクトに副作用が同じスカラオブジェクトの値を使用して、値の計算に相対非配列されている場合、動作は未定義です.
Original:
If a side effect on a scalar object is unsequenced relative to a value computation using the value of the same scalar object, the behavior is undefined.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

f(i, i++); // undefined behavior
a[i] = i++; // undefined bevahior

3)

Original:
The above rules apply as long as at least one allowable ordering of subexpressions permits such an unsequenced side-effect.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

### [編集]参照

Original:

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.