|
919 | 919 | Certain other operations are described in this document as |
920 | 920 | undefined behavior (for example, the effect of |
921 | 921 | attempting to modify a const object). |
| 922 | + |
| 923 | +\pnum |
| 924 | +Certain events in the execution of a program |
| 925 | +are termed \defnadj{observable}{checkpoints}. |
922 | 926 | \begin{note} |
923 | | -This document imposes no requirements on the |
924 | | -behavior of programs that contain undefined behavior. |
| 927 | +A call to \tcode{std::observable}\iref{utility.undefined} |
| 928 | +is an observable checkpoint. |
925 | 929 | \end{note} |
926 | 930 |
|
927 | 931 | \pnum |
928 | 932 | \indextext{program!well-formed}% |
929 | 933 | \indextext{behavior!observable}% |
| 934 | +The \defnadj{defined}{prefix} of an execution |
| 935 | +comprises the operations $O$ |
| 936 | +for which for every undefined operation $U$ |
| 937 | +there is an observable checkpoint $C$ |
| 938 | +such that $O$ happens before $C$ and |
| 939 | +$C$ happens before $U$. |
| 940 | + |
| 941 | +\begin{note} |
| 942 | +The undefined behavior that arises from a data race\iref{intro.races} |
| 943 | +occurs on all participating threads. |
| 944 | +\end{note} |
| 945 | + |
930 | 946 | A conforming implementation executing a well-formed program shall |
931 | | -produce the same observable behavior as one of the possible executions |
932 | | -of the corresponding instance of the abstract machine with the |
| 947 | +produce the observable behavior |
| 948 | +of the defined prefix |
| 949 | +of one of the possible executions |
| 950 | +of the corresponding instance |
| 951 | +of the abstract machine with the |
933 | 952 | same program and the same input. |
934 | 953 | \indextext{behavior!undefined}% |
935 | | -However, if any such execution contains an undefined operation, this document places no |
936 | | -requirement on the implementation executing that program with that input |
937 | | -(not even with regard to operations preceding the first undefined |
938 | | -operation). |
| 954 | +If the selected execution contains an undefined operation, |
| 955 | +the implementation executing that program with that input |
| 956 | +may produce arbitrary additional observable behavior afterwards. |
939 | 957 | If the execution contains an operation specified as having erroneous behavior, |
940 | 958 | the implementation is permitted to issue a diagnostic and |
941 | 959 | is permitted to terminate the execution |
|
953 | 971 |
|
954 | 972 | \pnum |
955 | 973 | \indextext{conformance requirements}% |
956 | | -The least requirements on a conforming implementation are: |
| 974 | +The following specify the |
| 975 | +\defnadj{observable}{behavior} |
| 976 | +of the program: |
957 | 977 | \begin{itemize} |
958 | 978 | \item |
959 | 979 | Accesses through volatile glvalues are evaluated strictly according to the |
960 | 980 | rules of the abstract machine. |
961 | 981 | \item |
962 | | -At program termination, all data written into files shall be |
963 | | -identical to one of the possible results that execution of the program |
964 | | -according to the abstract semantics would have produced. |
| 982 | +Data is delivered to the host environment to be written into files (\xrefc{7.21.3}). |
| 983 | + |
| 984 | +\begin{note} |
| 985 | +Delivering such data |
| 986 | +is followed by an observable checkpoint\iref{cstdio.syn}. |
| 987 | +Not all host environments provide access to file contents before program termination. |
| 988 | +\end{note} |
| 989 | + |
965 | 990 | \item |
966 | 991 | The input and output dynamics of interactive devices shall take |
967 | 992 | place in such a fashion that prompting output is actually delivered before a program waits for input. What constitutes an interactive device is |
968 | 993 | \impldef{interactive device}. |
969 | 994 | \end{itemize} |
970 | 995 |
|
971 | | -These collectively are referred to as the |
972 | | -\defnx{observable behavior}{behavior!observable} of the program. |
973 | 996 | \begin{note} |
974 | 997 | More stringent correspondences between abstract and actual |
975 | 998 | semantics can be defined by each implementation. |
|
0 commit comments