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

2024-12-19


1962. Type of __func__

Section: 9.5.1  [dcl.fct.def.general]     Status: open     Submitter: Steve Clamage     Date: 2014-07-04     Liaison: EWG

Two questions have arisen regarding the treatment of the type of the __func__ built-in variable. First, some implementations accept

  void f() {
    typedef decltype(__func__) T;
    T x = __func__;
  }

even though T is specified to be an array type.

In a related question, it was noted that __func__ is implicitly required to be unique in each function, and that not only the value but the type of __func__ are implementation-defined; e.g., in something like

  inline auto f() { return &__func__; }

the function type is implementation-specific. These concerns could be addressed by making the value a prvalue of type const char* instead of an array lvalue.

Notes from the May, 2015 meeting:

CWG agreed with the suggested direction.

Rationale (November, 2018):

See also issue 2362, which asks for the ability to use __func__ in a constexpr function. These two goals are incompatible, so EWG input is requested.

EWG 2022-11-11

Paper requested. This is tracked in github issue cplusplus/papers#1375.