2

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?

João Afonso
  • 1,934
  • 13
  • 19
  • Since the thread was about whether or not to hyphenate "full-expression", OP could also have meant that removing the hyphen would make it more ambiguous to tell that it's actually an expression. – Das_Geek May 20 '19 at 13:14
  • 2
    I think the discussion you refer to is just about distinguishing between "full expression" being not standard language while "full-expression" is – 463035818_is_not_an_ai May 20 '19 at 13:15
  • imho it would be better if you could rerphase the question to not refer to the posts on github. Only OP can know what they really meant with that comment – 463035818_is_not_an_ai May 20 '19 at 13:21

1 Answers1

1

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.

NathanOliver
  • 171,901
  • 28
  • 288
  • 402
  • Brilliant! But I'm still in doubt about the following: why did the spec have to include a _declarator_ (used in the definition of a _init-declarator_) and a _mem-initializer-id_ (used in the definition of a _mem-initializer_), in the definition of a _full-expression_??? – João Afonso May 20 '19 at 13:58
  • @JoãoAfonso Because they are full expressions. That is why you can do things like `int i = 3, a = i++, b = i++;` or `foo(int i) : a(i++), b(i++) {}` and have defined behavior. Each declarator is a full expression so there is no conflict for when `i++` is evaluated. That same thing happens in member initializers. – NathanOliver May 20 '19 at 14:01