Title
Value-initialization and constexpr constructor evaluation
Status
open
Section
7.7 [expr.const]
Submitter
Daveed Vandevoorde

Created on 2016-04-18.00:00:00 last changed 104 months ago

Messages

Date: 2016-04-18.00:00:00

Consider the following example:

  union A {
    constexpr A(int) : x(++x) { }
    int x;
    char* y;
  };
  union B {
    A a = 5;
  };
  int arr[B().a.x];

Value-initialization of the object created by B() zero-initializes the object (9.4 [dcl.init] bullet 8.2), which should mean that the ++x in the mem-initilizer for A operates on a zero-initialized object, but current implementations reject this code as non-constant. It is not clear what in the current wording justifies this treatment.

History
Date User Action Args
2016-04-18 00:00:00admincreate