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

2026-03-06


3162. Evaluation context of manifestly constant-evaluated expressions

Section: 7.7  [expr.const]     Status: open     Submitter: Dan Katz     Date: 2026-02-13

(From submission #848.)

Consider:

  struct S;
  consteval size_t f() {
    constexpr bool b = is_complete_type(^^S);
    return b ? 1 : 2;
  }

  struct T;
  consteval {
    define_aggregate(^^S, {});
    define_aggregate(^^T, {
      data_member_spec(^^int, {.name="m", .bit_width=f()}),
   });
  }

  int main() {
    return bit_size_of(^^T::m);
  }

The Working Draft arguably says that this program should exit with status 1: During the evaluation of the expression corresponding to the consteval-block, the evaluation of is_complete_type(^^S) contains the synthesized point associated with the injected declaration of S; therefore, the type is complete.

But this was never the intention of P2996; the intention was to evaluate manifestly constant-evaluated expressions at the point where they appear. The problem is that we didn't consider manifestly constant-evaluated expressions that might be executed (formally, per the abstract machine) during the evaluation of other manifestly constant-evaluated expressions.

Suggested resolution:

This also resolves issue 3127.

Change in 7.7 [expr.const] paragraph 30 as follows:

During an evaluation V (6.10.1 [intro.execution]) of an expression, conversion, or initialization E as a core constant expression, the point of evaluation of E during V is the program point P determined as follows:
The evaluation context evaluation context is a set of program points that determines the behavior of certain functions used for reflection (21.4 [meta.reflection]). During the evaluation V of an expression E as a core constant expression, the evaluation context evaluation context of an evaluation X (6.10.1 [intro.execution]) consists of the following points during V is the set C of program points determined as follows: