Skip to content

Commit a6e579f

Browse files
committed
CWG2855 Undefined behavior in postfix increment
1 parent 019651b commit a6e579f

File tree

1 file changed

+6
-27
lines changed

1 file changed

+6
-27
lines changed

source/expressions.tex

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3764,7 +3764,7 @@
37643764
An operand with volatile-qualified type is deprecated;
37653765
see~\ref{depr.volatile.type}.
37663766
The value of the operand object is modified\iref{defns.access}
3767-
by adding \tcode{1} to it.
3767+
as if it were the operand of the prefix \tcode{++} operator\iref{expr.pre.incr}.
37683768
The
37693769
\indextext{value computation}%
37703770
value computation of the \tcode{++} expression is sequenced before the
@@ -3779,11 +3779,6 @@
37793779
\end{note}
37803780
The result is a prvalue. The type of the result is the cv-unqualified
37813781
version of the type of the operand.
3782-
If the operand is a bit-field that cannot represent the incremented value, the
3783-
resulting value of the bit-field is
3784-
\impldefplain{value of bit-field that cannot represent!incremented value}.
3785-
See also~\ref{expr.add}
3786-
and~\ref{expr.ass}.
37873782

37883783
\pnum
37893784
\indextext{expression!decrement}%
@@ -4785,32 +4780,16 @@
47854780
\pnum
47864781
\indextext{expression!increment}%
47874782
\indextext{expression!decrement}%
4788-
The operand of prefix \tcode{++}
47894783
\indextext{operator!increment}%
4784+
\indextext{operator!decrement}%
47904785
\indextext{prefix \tcode{++}}%
4791-
is modified\iref{defns.access} by adding \tcode{1}.
47924786
\indextext{prefix \tcode{--}}%
4793-
The operand shall be a modifiable lvalue. The type of the operand shall
4794-
be an arithmetic type other than \cv{}~\tcode{bool},
4795-
or a pointer to a completely-defined object type.
4787+
The operand of prefix \tcode{++} or \tcode{--}
4788+
shall not be of type \cv{}~\tcode{bool}.
47964789
An operand with volatile-qualified type is deprecated;
47974790
see~\ref{depr.volatile.type}.
4798-
The result is the updated operand; it is an lvalue, and it is a
4799-
bit-field if the operand is a bit-field.
4800-
The expression \tcode{++x} is equivalent to \tcode{x+=1}.
4801-
\indextext{operator!\idxcode{+=}}%
4802-
\begin{note}
4803-
See the discussions of addition\iref{expr.add} and assignment
4804-
operators\iref{expr.ass} for information on conversions.
4805-
\end{note}
4806-
4807-
\pnum
4808-
The operand of prefix
4809-
\indextext{operator!decrement}%
4810-
\tcode{--} is modified\iref{defns.access} by subtracting \tcode{1}.
4811-
The requirements on the operand of prefix
4812-
\tcode{--} and the properties of its result are otherwise the same as
4813-
those of prefix \tcode{++}.
4791+
The expression \tcode{++x} is otherwise equivalent to \tcode{x+=1} and
4792+
the expression \tcode{--x} is otherwise equivalent to \tcode{x-=1}\iref{expr.ass}.
48144793
\begin{note}
48154794
For postfix increment and decrement, see~\ref{expr.post.incr}.
48164795
\end{note}

0 commit comments

Comments
 (0)