This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 115e. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2024-11-11


2217. constexpr constructors for non-literal types

Section: 9.2.6  [dcl.constexpr]     Status: NAD     Submitter: Daveed Vandevoorde     Date: 2015-12-21

Given an example like:

  struct S {
    constexpr S(): i(42) {  }
    ~S();
    int i;
  };
  double x[S().i];  // Error

such a constexpr constructor is completely useless, but there doesn't appear to be anything in the current wording making it ill-formed. Should it be?

Rationale (November, 2016):

Such constructors can be useful for guaranteeing static initialization of namespace-scope objects.