In fact, the C standard is relatively relatively loose for specific compilers. The C standard defines a "abstract machine" on the basis of its semantic logic, which ensures a corresponding operation of the semantic logic of the C program. C compiler implementation as long as the behavior of its implementation programs in its implementation, it can be consistent with this abstract machine. This section pointed out the relationship between implementation with the virtual machine, how to determine if an implementation and standard meet, side effects, and sequential concepts.
1.9 program execution [Intro.execution]
The semantic descriptions in this International Standard define a parameterized nondeterministic abstract machine. This International Standard places no requirement on the structure of conforming implementations. In particular, they need not copy or emulate the structure of the abstract machine. Rather, conforming implementations are required to Emulate (only) The obstract machine as explained BELOW.I) In the semantic description of this standard, a parameterized, unspecified abstract machine is defined. This standard does not set any specifications for internal structures that meet the standard implementation. Realization, especially the structure, which does not need to be copied or imitated, and need to mimic (only) is an observable behavior of abstract machines. Abstract machines are described below. i) i) This provision is sometimes called the "as-if" rule, because an implementation is free to disregard any requirement of this International Standard as long as the result is as if the requirement had been obeyed, as far as can be determined from the observable behavior of the program. For instance, an actual implementation need not evaluate part of an expression if it can deduce that its value is not used and that no side effects affecting the observable behavior of the program are produced. this provision is often It is called "seemingly" principles because as long as the results of the implementation can be considered to comply with the specifications of this standard by examining the results of this standard, it is possible to ignore any standard specifications. For example, if a particular implementation can derive a certain value of a part of the expression is not used, and this part of the expression is not affected by the observable behavior generated by the program, this implementation does not need to Part of the expression is evaluated.
Certain aspects and operations of the abstract machine are described in this International Standard as implementation-defined (for example, sizeof (int)). These constitute the parameters of the abstract machine. Each implementation shall include documentation describing its characteristics and behavior in these respects .,. ). These have formed the implementation parameters of the virtual machine. Each implementation should provide document description to their specific features and behavior. The implementation of the documentation should be defined as an instance of the virtual machine corresponding to the implementation ("Correspondence Instance" as follows). Certain other aspects and operations of the abstract machine are described in this International Standard as unspecified (for example, order of evaluation of arguments to a function). Where possible, this International Standard defines a set of allowable behaviors. These define the nondeterministic aspects of The Abstract Machine. An Instance of the Abstract Machine Can Thus Have More Than One Possible Execution Sequence for a Given Program And A Given Input. This standard describes other aspects and operations of the virtual machine as unmetuted (such as the function parameters. Value order). This standard defines a set of acceptable behaviors in a possible situation. This defines the aspect of the abstract machine's non-determination. For a known program and known data, an instance of a virtual machine will generate less than one possible execution sequence due to its non-determination.
Certain other operations are described in this International Standard as undefined (for example, the effect of dereferencing the null pointer) [Note:. This International Standard imposes no requirements on the behavior of programs that contain undefined behavior]. Other operations are the present standard known Undefined (such as the consequences of the null pointer). [Note: This standard does not make any specification for the behavior of programs that contain undefined behavior. 】
A conforming implementation executing a well-formed program shall produce the same observable behavior as one of the possible execution sequences of the corresponding instance of the abstract machine with the same program and the same input. However, if any such execution sequence contains an undefined operation , this International standard places no requirement on when the implementation executing that program with that input (not even with regard to operations preceding the first undefined operation). when a standards-compliant implementation of the implementation of a comprehensive program, which produces observable behavior should An abstract machine corresponding to the implementation is the same as one of the possible execution sequences generated by the same procedure and the same output. Despite this, if there is an undefined behavior in this execution sequence, this standard does not perform any specification for the implementation of this program that implements this input data (excluding operations prior to the first undefined operation). The Observable Behavior of the Abstract Machine Is Its Sequence of Reads and Writes To Library I / O Functions.ii) Observer Abstract Machine is its read and write and library I / O functions for Volatile data Calling sequence. II) II) An Implementation CAN Offer Additional Library. Implementation That Do So SHOULD TREAT CALLS THOSE FUNSELD TREAT CALLS THOSE FUNSELD TREAT CALLS THOSE FUNSELD TREAT CALLS THOSE FUNSELD TREAT CALLS THOSE FUNSETY "OBSERVABLE BEHAVIOR" AS Well. Implementation can provide additional I / O library function as an extension, implementation The call to these functions should also be regarded as "observable behavior".
Accessing an object designated by a volatile lvalue (3.10), modifying an object, calling a library I / O function, or calling a function that does any of those operations are all side effects, which are changes in the state of the execution environment. Evaluation of an expression might produce side effects. At certain specified points in the execution sequence called sequence points, all side effects of previous evaluations shall be complete and no side effects of subsequent evaluations shall have taken place.iii) to access a left-labeled volatile Value (3.10) object, change an object, call the I / O library function, or call a function of any function that makes any such operation, has side effects, and side effects change the status of the execution environment. The evaluation of the expression may bring side effects. In certain points of certain sequences known as orderly, all the side effects brought by all the previous evaluations must have been completed, and the side effects of all subsequent execution sequences have not occurred yet. iii) iii) Note that some aspects of sequencing in the abstract machine are unspecified;. the preceding restriction upon side effects applies to that particular execution sequence in which the actual code is generated Also note that when a call to a library I / O function Returns, The Side Effect Is Considered Complete, Even Though Some External Actions Implied by The Call (Such as The I / O Itself) May Not Have completed yet. Note that in some cases the order of abstract machine execution is not specified; Restrictions on side effects apply to the execution sequences that generate actual code. Also, when returning from the I / O library function, even if some external actions executed by this function (such as hardware I / O action itself) have not completed, the side effects of this function call is still considered to be completed. Once The Expection of a Function Begins, No Expressions from the calling function is evaction haus completion. Once an called function starts, the expression in any caller function must be adjusted After the function is completed. IV) IV) In Other Words, Function Executions Do Not Interleave with each other. That is, the execution of the function will not cross each other.
When the processing of the abstract machine is interrupted by receipt of a signal, the value of objects with type other than volatile sig_atomic_t are unspecified, and the value of any object not of volatile sig_atomtic_t that is modified by the handler becomes undefined. When the abstract machine Due to the interruption of the received signal, any type of object other than the Volatile Sig_ATomic_T is not specified. The value of any type of object except for the signal processor change will become unregulated in addition to the value of the Volatile Sig_ATomic_T. An instance of each object with automatic storage duration (3.7.2) is associated with each entry into its block. Such an object exists and retains its last-stored value during the execution of the block and while the block is suspended (by a call The of a function or receipt of a signal. Each instance with an automatic storage class (3.7.2) object is associated with the corresponding entry of its statement block. This object will always exist during the execution of the block and when the block is suspended, and always maintain its nearest saved value.
The Least Requirements on a CONFORMING IMPLEMENTATION ARE: The minimum requirement for standard implementation:
At SEQUENCE POINTS, VOLATILE OBJECTS Are Stable in The Sense That Previous Evaluations Are Complete and Subsequent Evaluations Are Complete and Subsequent Evaluations Are Complete and Subsequent Evaluations Are Complete and Subsequent Evaluations Are Complete And Subsequent Evaluations Area, the value of the Volatile object should have been completed, and the results should have not occurred yet, The Volatile object should be stable. At program termination, all data written into files shall be identical to one of the possible results that execution of the program according to the abstract semantics would have produced. When the program terminates, all data written to the file, should this abstract semantic The program executes one of all possible results that can cause. Dynamic behavior The input and output dynamics of interactive devices shall take place in such a fashion that prompting messages actually appear prior to a program waiting for input. What constitutes an interactive device is implementation-defined. The interactive input device output should be expressed as : Output prompt information before the program enters waiting input. The actual composition of the interactive device is defined by implementation.
[Note: More Stringent Correspondences Between Abstract and actual semantics may be defined by Each Implementation.] [Note: Abstract and actual semantics more stringent correspondence may be defined by each implementation. ] A full-expression is an expression that is not a subexpression of another expression. If a language construct is defined to produce an implicit call of a function, a use of the language construct is considered to be an expression for the purposes of this definition .
[Note:. Certain contexts in C cause the evaluation of a full-expression that results from a syntactic construct other than expression (5.18) For example, in 8.5 one syntax for initializer is (expression-list) but the resulting construct is a function call upon a constructor function with expression-list as an argument list;. such a function call is a full-expression for example, in 8.5, another syntax for initializer is = initializer-clausebut again the resulting construct might be a function call upon a Constructor Function With Assignment-Expression As an Argument; Again, The Function Call Is A Full-Expression.] D
[Note:. The evaluation of a full-expression can include the evaluation of subexpressions that are not lexically part of the full-expression For example, subexpressions involved in evaluating default argument expressions (8.3.6) are considered to be created in the expression That Calls The Function, NOT The Expression That Defines The default argument.] d
[Note: operators can be regrouped according to the usual mathematical rules only where the operators really are associative or commutative.v) For example, in the following fragment int a, b; /*...*/ a = a 32760 B 5; The Expression Statement Behaves Exactly The Same AS A = (((A 32760) B) 5); Due To The Associative and Precedency of these Operators. Thus, The Result of the Sum (A 32760) is next added to b, and that result is then added to 5 which results in the value assigned to a. On a machine in which overflows produce an exception and in which the range of values representable by an int is [-32768, 32767 ], The Implementation Cannot ReWrite this Expression As A = ((A B) 32765); Since if The VALUES for A and B WERE, RESPECTIELY, -32754 and -15, The Sum A B Would Produce An Exception While T ORIGINAL EXPRESSION WOULD NOT; NOR CAN THE EXPRESSION BE REWRITTEN EIGER AS A = ((A 32765) B); OR A = (A (B 32765)); Since The VALUES for A and B MIG ht have been, respectively, 4 and -8 or -17 and 12. However on a machine in which overflows do not produce an exception and in which the results of overflows are reversible, the above expression statement can be rewritten by the implementation in any Of The Above Ways Because The Same Result Will Occur.] DV) Overloaded Operators Are Never Assumed to Be Associative or Commmutative.d
There is a sequence point at the completion of evaluation of each full-expressionvi) .dvi) As specified in 12.2, after the "end-of-full-expression" sequence point, a sequence of zero or more invocations of destructor functions for temporary objects takes place, usually in reverse order of the construction of each temporary object.dWhen calling a function (whether or not the function is inline), there is a sequence point after the evaluation of all function arguments (if any) which takes place before execution of any expressions or statements in the function body. There is also a sequence point after the copying of a returned value and before the execution of any expressions outside the functionvii). Several contexts in C cause evaluation of a function call, even though no Corresponding Function Call Syntax Appears in The Translation UNIT. [EXAMPLE: Evaluation of a New Expression Invocation of a conversion function (12.3.2) Can Arise In Contexts in Which No Function Call Syntax Appears .] The sequence points at function-entry and function-exit (as described above) are features of the function calls as evaluated, whatever the syntax of the expression that calls the function might be.dvii) The sequence point at the function return is not explicitly specified in ISO C, and can be considered redundant with sequence points at full-expressions, but the extra clarity is important in C . in C , there are more ways in which a called function can terminate its execution, such as the throw Of an expression.d