Skip to content

Commit ef43fb3

Browse files
committed
CWG1642 Missing requirements for prvalue operands
1 parent b3e0421 commit ef43fb3

File tree

2 files changed

+36
-19
lines changed

2 files changed

+36
-19
lines changed

source/declarations.tex

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4696,8 +4696,9 @@
46964696
\item
46974697
Otherwise, the initial value of the object being initialized is
46984698
the (possibly converted) value of the initializer expression.
4699-
A standard conversion sequence\iref{conv} will be used, if necessary,
4700-
to convert the initializer expression to the cv-unqualified version of
4699+
A standard conversion sequence\iref{conv} is used
4700+
to convert the initializer expression to
4701+
a prvalue of the cv-unqualified version of
47014702
the destination type;
47024703
no user-defined conversions are considered.
47034704
If the conversion cannot

source/expressions.tex

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@
246246

247247
\pnum
248248
Whenever a glvalue appears as an operand of an operator that
249-
expects a prvalue for that operand, the
249+
requires a prvalue for that operand, the
250250
lvalue-to-rvalue\iref{conv.lval}, array-to-pointer\iref{conv.array},
251251
or function-to-pointer\iref{conv.func} standard conversions are
252252
applied to convert the expression to a prvalue.
@@ -518,7 +518,8 @@
518518
conversions.
519519
\end{note}
520520
A standard conversion sequence will be applied to
521-
an expression if necessary to convert it to a required destination type.
521+
an expression if necessary to convert it to an expression having
522+
a required destination type and value category.
522523

523524
\pnum
524525
\begin{note}
@@ -1120,6 +1121,10 @@
11201121
which are defined as follows:
11211122

11221123
\begin{itemize}
1124+
\item The lvalue-to-rvalue conversion\iref{conv.lval}
1125+
is applied to each operand and
1126+
the resulting prvalues are used in place of the original operands
1127+
for the remainder of this section.
11231128
\item If either operand is of scoped enumeration type\iref{dcl.enum}, no conversions
11241129
are performed; if the other operand does not have the same type, the expression is
11251130
ill-formed.
@@ -3169,10 +3174,10 @@
31693174
The postfix expression shall
31703175
have function type or function pointer type.
31713176
For a call to a non-member function or to a static member function,
3172-
the postfix expression shall either be an lvalue that refers to a
3177+
the postfix expression shall be either an lvalue that refers to a
31733178
function (in which case the function-to-pointer standard
31743179
conversion\iref{conv.func} is suppressed on the postfix expression),
3175-
or have function pointer type.
3180+
or a prvalue of function pointer type.
31763181

31773182
\pnum
31783183
If the selected
@@ -4611,14 +4616,16 @@
46114616

46124617
\pnum
46134618
\indextext{operator!unary plus}%
4614-
The operand of the unary \tcode{+} operator shall have arithmetic, unscoped
4619+
The operand of the unary \tcode{+} operator shall be a prvalue of
4620+
arithmetic, unscoped
46154621
enumeration, or pointer type and the result is the value of the
46164622
argument. Integral promotion is performed on integral or enumeration
46174623
operands. The type of the result is the type of the promoted operand.
46184624

46194625
\pnum
46204626
\indextext{operator!unary minus}%
4621-
The operand of the unary \tcode{-} operator shall have arithmetic or unscoped
4627+
The operand of the unary \tcode{-} operator shall be a prvalue of
4628+
arithmetic or unscoped
46224629
enumeration type and the result is the negative of its operand. Integral
46234630
promotion is performed on integral or enumeration operands. The negative
46244631
of an unsigned quantity is computed by subtracting its value from $2^n$,
@@ -4639,7 +4646,8 @@
46394646

46404647
\pnum
46414648
\indextext{operator!ones' complement}%
4642-
The operand of the \tcode{\~{}} operator shall have integral or unscoped enumeration type.
4649+
The operand of the \tcode{\~{}} operator shall be a prvalue of
4650+
integral or unscoped enumeration type.
46434651
Integral promotions are performed.
46444652
The type of the result is the type of the promoted operand.
46454653
% FIXME: [basic.fundamental]/p5 uses $x_i$; [expr] uses $\tcode{x}_i$.
@@ -5655,15 +5663,16 @@
56555663
that consists of empty square brackets can follow the \keyword{delete} keyword
56565664
if the \grammarterm{lambda-expression} is enclosed in parentheses.
56575665
\end{footnote}
5658-
The operand shall be of pointer to object type or of class type. If of
5659-
class type, the operand is contextually implicitly converted\iref{conv}
5666+
If the operand is of
5667+
class type, it is contextually implicitly converted\iref{conv}
56605668
to a pointer to object
56615669
type.
56625670
\begin{footnote}
56635671
This implies that an object
56645672
cannot be deleted using a pointer of type
56655673
\tcode{\keyword{void}*} because \keyword{void} is not an object type.
56665674
\end{footnote}
5675+
Otherwise, it shall be a prvalue of pointer to object type.
56675676
The \grammarterm{delete-expression} has type
56685677
\keyword{void}.
56695678

@@ -6020,6 +6029,7 @@
60206029

60216030
\pnum
60226031
The binary operator \tcode{.*} binds its second operand, which shall be
6032+
a prvalue
60236033
of type ``pointer to member of \tcode{T}'' to its first operand, which shall be
60246034
a glvalue
60256035
of
@@ -6029,6 +6039,7 @@
60296039

60306040
\pnum
60316041
The binary operator \tcode{->*} binds its second operand, which shall be
6042+
a prvalue
60326043
of type ``pointer to member of \tcode{T}'' to its first operand, which shall be of
60336044
type ``pointer to \tcode{U}''
60346045
where \tcode{U} is either \tcode{T} or
@@ -6152,9 +6163,14 @@
61526163
\indextext{operator!additive}
61536164

61546165
\pnum
6155-
The additive operators \tcode{+} and \tcode{-} group left-to-right. The
6156-
usual arithmetic conversions\iref{expr.arith.conv} are performed for operands of arithmetic or
6157-
enumeration type.
6166+
The additive operators \tcode{+} and \tcode{-} group left-to-right.
6167+
Each operand shall be a prvalue.
6168+
If both operands have arithmetic or unscoped enumeration type,
6169+
the usual arithmetic conversions\iref{expr.arith.conv} are performed.
6170+
Otherwise, if one operand has arithmetic or unscoped enumeration type,
6171+
integral promotion is applied\iref{conv.prom} to that operand.
6172+
A converted or promoted operand is used in place of
6173+
the corresponding original operand for the remainder of this section.
61586174

61596175
\indextext{operator!addition}%
61606176
\indextext{addition operator|see{operator, addition}}%
@@ -6171,22 +6187,22 @@
61716187
\end{bnf}
61726188

61736189
\indextext{incomplete}%
6174-
For addition, either both operands shall have arithmetic or unscoped enumeration
6190+
For addition, either both operands shall have arithmetic
61756191
type, or one operand shall be a pointer to a completely-defined object
6176-
type and the other shall have integral or unscoped enumeration type.
6192+
type and the other shall have integral type.
61776193

61786194
\pnum
61796195
For subtraction, one of the following shall hold:
61806196
\begin{itemize}
6181-
\item both operands have arithmetic or unscoped enumeration type; or
6197+
\item both operands have arithmetic type; or
61826198

61836199
\item
61846200
\indextext{arithmetic!pointer}%
61856201
both operands are pointers to cv-qualified or cv-unqualified
61866202
versions of the same completely-defined object type; or
61876203

61886204
\item the left operand is a pointer to a completely-defined object type
6189-
and the right operand has integral or unscoped enumeration type.
6205+
and the right operand has integral type.
61906206
\end{itemize}
61916207

61926208
\pnum
@@ -6289,7 +6305,7 @@
62896305
shift-expression \terminal{>>} additive-expression
62906306
\end{bnf}
62916307

6292-
The operands shall be of integral or unscoped enumeration type and integral
6308+
The operands shall be prvalues of integral or unscoped enumeration type and integral
62936309
promotions are performed. The type of the result is that of the promoted
62946310
left operand.
62956311
\indextext{left shift!undefined}%

0 commit comments

Comments
 (0)