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


2559. Defaulted consteval functions

Section: 7.7  [expr.const]     Status: open     Submitter: Aaron Ballman     Date: 2022-03-29

Consider:

  template <typename Ty>
  struct S {
    Ty i;
    consteval S() = default;
  };

  template <typename Ty>
  struct T {
    Ty i;
    consteval T() {}
  };

  S<int> one; // only Clang rejects
  T<int> two; // Clang, GCC, ICC, MSVC reject

  void locals() {
    S<int> three; // only Clang rejects
    T<int> four;  // Clang, GCC, ICC, MSVC reject
  }

A consteval function should always be evaluated at compile time and never fall back to runtime, thus all four cases should be rejected. Issue 2558 is related.