Title
Constant expressions, aggregate initialization, and modifications
Status
open
Section
8.20 [expr.const]
Submitter
Mike Miller

Created on 2017-10-31.00:00:00, last changed 2017-10-31.00:00:00.

Messages

Date: 2017-10-31.00:00:00

There is implementation variance in the treatment of the following example:

  constexpr int f(int x) { return x; }
  int main() {
    struct {
      int x = f(x = 37);
    } constexpr a = { };
  } 

Is the assignment to x considered to satisfy the requirememts of 8.20 [expr.const] bullet 2.17,

modification of an object (8.18 [expr.ass], 8.2.6 [expr.post.incr], 8.3.2 [expr.pre.incr]) unless it is applied to a non-volatile lvalue of literal type that refers to a non-volatile object whose lifetime began within the evaluation of e;

assuming that e is the full-expression encompassing the initialization of a?

History
Date User Action Args
2017-10-31 00:00:00admincreate