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


2362. __func__ should be constexpr

Section: 9.5.1  [dcl.fct.def.general]     Status: open     Submitter: Anthony Polukhin     Date: 2017-10-23     Liaison: EWG

The definition of __func__ in 9.5.1 [dcl.fct.def.general] paragraph 8 is:

  static const char __func__[] = "function-name";

This prohibits its use in constant expressions, e.g.,

  int main () {
    // error: the value of __func__ is not usable in a constant expression
    constexpr char c = __func__[0];
  }

Notes from the October, 2018 teleconference:

CWG agreed with the proposed change.

Rationale (November, 2018):

See also issue 1962, which asks that the type of __func__ be const char*. These two goals are incompatible, so EWG input is requested.

EWG 2022-11-11

This is tracked in github issue cplusplus/papers#1378.