c++language-lawyerfull-expression

"full-expression" versus "full expression"


I was looking at this post in GitHub, but I couldn't understand what the OP meant by this:

"full expression" suggest that it is a kind of expression, but sometimes it is not.

My interpretation is that a "full-expression" (term used in the Standard) may not be an expression. [intro.execution]/5 gives the definition for full-expression, as follows:

A full-expression is
(5.1) — an unevaluated operand (8.2),
(5.2) — a constant-expression (8.6),
(5.3) — an init-declarator (Clause 11) or a mem-initializer (15.6.2), including the constituent expressions of the initializer,
(5.4) — an invocation of a destructor generated at the end of the lifetime of an object other than a temporary object (15.2), or
(5.5) — an expression that is not a subexpression of another expression and that is not otherwise part of a full-expression.

If my interpretation is correct I would like to know which of the bullet points above yields a full-expression that is not an expression. Otherwise, i.e., if I'm wrong, what did the OP mean by his comment?


Solution

  • The formal list of expressions can be found in [gram.expr]. It is quite a bit of text so I am not going to include it here but using it we can see that an init-declarator and a mem-initializer are not expressions according to the grammar. That means even though an init-declarator and a mem-initializer are considered full expressions, grammatically they are not expressions.