|
3115 | 3115 | \end{note}
|
3116 | 3116 |
|
3117 | 3117 | \pnum
|
3118 |
| -A \defn{memory location} is either an object of scalar type that is not a bit-field |
| 3118 | +A \defn{memory location} is |
| 3119 | +the storage occupied by the object representation of |
| 3120 | +either an object of scalar type that is not a bit-field |
3119 | 3121 | or a maximal sequence of adjacent bit-fields all having nonzero width.
|
3120 | 3122 | \begin{note}
|
3121 | 3123 | Various
|
|
6037 | 6039 | \end{note}
|
6038 | 6040 | The value computations of the operands of an
|
6039 | 6041 | operator are sequenced before the value computation of the result of the
|
6040 |
| -operator. If a |
| 6042 | +operator. |
| 6043 | +The behavior is undefined if |
| 6044 | +\begin{itemize} |
| 6045 | +\item |
6041 | 6046 | \indextext{side effects}%
|
6042 |
| -side effect on a memory location\iref{intro.memory} is unsequenced |
6043 |
| -relative to either another side effect on the same memory location or |
| 6047 | +a side effect on a memory location\iref{intro.memory} or |
| 6048 | +\item |
| 6049 | +starting or ending the lifetime of an object in a memory location |
| 6050 | +\end{itemize} |
| 6051 | +is unsequenced relative to |
| 6052 | +\begin{itemize} |
| 6053 | +\item |
| 6054 | +another side effect on the same memory location, |
| 6055 | +\item |
| 6056 | +starting or ending the lifetime of an object occupying storage that |
| 6057 | +overlaps with the memory location, or |
| 6058 | +\item |
6044 | 6059 | a value computation using the value of any object in the same memory location,
|
6045 |
| -and they are not potentially concurrent\iref{intro.multithread}, |
6046 |
| -the behavior is undefined. |
| 6060 | +\end{itemize} |
| 6061 | +and the two evaluations are not potentially concurrent\iref{intro.multithread}. |
| 6062 | +\begin{note} |
| 6063 | +Starting the lifetime of an object in a memory location can end the lifetime of |
| 6064 | +objects in other memory locations\iref{basic.life}. |
| 6065 | +\end{note} |
6047 | 6066 | \begin{note}
|
6048 | 6067 | The next subclause imposes similar, but more complex restrictions on
|
6049 | 6068 | potentially concurrent computations.
|
|
6057 | 6076 | i = i++ + 1; // the value of \tcode{i} is incremented
|
6058 | 6077 | i = i++ + i; // undefined behavior
|
6059 | 6078 | i = i + 1; // the value of \tcode{i} is incremented
|
| 6079 | + |
| 6080 | + union U { int x, y; } u; |
| 6081 | + (u.x = 1, 0) + (u.y = 2, 0); // undefined behavior |
6060 | 6082 | }
|
6061 | 6083 | \end{codeblock}
|
6062 | 6084 | \end{example}
|
|
6167 | 6189 | \end{note}
|
6168 | 6190 |
|
6169 | 6191 | \pnum
|
6170 |
| -Two expression evaluations \defn{conflict} if one of them modifies\iref{defns.access} a memory |
6171 |
| -location\iref{intro.memory} and the other one reads or modifies the same |
6172 |
| -memory location. |
| 6192 | +Two expression evaluations \defn{conflict} if one of them |
| 6193 | +\begin{itemize} |
| 6194 | +\item |
| 6195 | +modifies\iref{defns.access} a memory location\iref{intro.memory} or |
| 6196 | +\item |
| 6197 | +starts or ends the lifetime of an object in a memory location |
| 6198 | +\end{itemize} |
| 6199 | +and the other one |
| 6200 | +\begin{itemize} |
| 6201 | +\item |
| 6202 | +reads or modifies the same memory location or |
| 6203 | +\item |
| 6204 | +starts or ends the lifetime of an object occupying storage that |
| 6205 | +overlaps with the memory location. |
| 6206 | +\end{itemize} |
6173 | 6207 | \begin{note}
|
6174 | 6208 | A modification can still conflict
|
6175 | 6209 | even if it does not alter the value of any bits.
|
|
0 commit comments