Title
Defaulted consteval functions
Status
open
Section
7.7 [expr.const]
Submitter
Aaron Ballman

Created on 2022-03-29.00:00:00 last changed 2 months ago

Messages

Date: 2022-03-29.00:00:00

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.

History
Date User Action Args
2022-03-29 00:00:00admincreate