Title
Failed consteval contracts while constructing a candidate set
Status
nad
Section
6.11.2 [basic.contract.eval]
Submitter
CWG

Created on 2026-03-25.00:00:00 last changed 1 week ago

Messages

Date: 2026-03-27.13:08:23

CWG 2026-03-27

The status quo specification is clear that the declaration (sans the defintion) of #3 is instantiated while constructing the candidate set, causing constant evaluation of v. Constant evaluation of a contract violation requires rejection of the program per 4.1.1 [intro.compliance.general] bullet 2.3.4.

Date: 2026-03-25.00:00:00

Consider:

  template<class T>
  constexpr int v(T x)
    pre(x > 0)
  {
    return x;        // #1
    // return *T();  // #2
  }

  template<int> struct C;

  template<class T>
    constexpr int f(C<v(T())> *) { return 1; }  // #3
  template<class T>
    constexpr int f(void*) { return 2; }              // #4

  static_assert(f<int>((void*)0) == 2);

In general, certain instantiations are optional; see 13.9.2 [temp.inst] paragraph 9.

History
Date User Action Args
2026-03-27 13:08:23adminsetmessages: + msg8527
2026-03-27 13:08:23adminsetstatus: open -> nad
2026-03-25 00:00:00admincreate