© ISO/IEC C++20 Latest Draft
4.1.2 Abstract machine [intro.abstract]
1
The semantic descriptions in this document define a parameterized nondeterministic abstract machine. This
document 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 observable behavior of the abstract machine as explained below.
7
2
Certain aspects and operations of the abstract machine are described in this document 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.
8
Such documentation shall define the instance of the abstract machine that corresponds to that implementation
(referred to as the “corresponding instance” below).
3
Certain other aspects and operations of the abstract machine are described in this document as unspecified
(for example, order of evaluation of arguments in a function call (7.6.1.3)). Where possible, this document
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 for a given program and a
given input.
4
Certain other operations are described in this document as undefined (for example, the effect of attempting
to modify a const object).
[Note 1: This document imposes no requirements on the behavior of programs that contain undefined behavior.
— end note]
5
A conforming implementation executing a well-formed program shall produce the same observable behavior as
one of the possible executions of the corresponding instance of the abstract machine with the same program
and the same input. However, if any such execution contains an undefined operation, this document places
no requirement on the implementation executing that program with that input (not even with regard to
operations preceding the first undefined operation).
6
The least requirements on a conforming implementation are:
—
(6.1)
Accesses through volatile glvalues are evaluated strictly according to the rules of the abstract machine.
—
(6.2)
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.
—
(6.3)
The input and output dynamics of interactive devices shall take place in such a fashion that prompting
output is actually delivered before a program waits for input. What constitutes an interactive device is
implementation-defined.
These collectively are referred to as the observable behavior of the program.
[Note 2 : More stringent correspondences between abstract and actual semantics can be defined by each implementation.
— end note]
4.2 Structure of this document [intro.structure]
1
Clause 5 through Clause 15 describe the C
++
programming language. That description includes detailed
syntactic specifications in a form described in 4.3. For convenience, Annex A repeats all such syntactic
specifications.
2
Clause 17 through Clause 32 and Annex D (the library clauses) describe the C
++
standard library. That
description includes detailed descriptions of the entities and macros that constitute the library, in a form
described in Clause 16.
3
Annex B recommends lower bounds on the capacity of conforming implementations.
4
Annex C summarizes the evolution of C
++
since its first published description, and explains in detail the
differences between C
++
and C. Certain features of C
++
exist solely for compatibility purposes; Annex D
describes those features.
7)
This provision is sometimes called the “as-if” rule, because an implementation is free to disregard any requirement of this
document 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.
8) This documentation also includes conditionally-supported constructs and locale-specific behavior. See 4.1.
§ 4.2 10