Skip to content

CWG2362 __func__ should be constexpr #1378

@jfbastien

Description

@jfbastien

Migrating from https://isocpp.org/files/papers/P1018R18.html#issues
CWG2362

Section: 9.5.1 [dcl.fct.def.general] Status: extension Submitter: Anthony Polukhin Date: 2017-10-23
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.

Meeting: handle with 1962.

Metadata

Metadata

Assignees

No one assigned

    Labels

    EWGEvolutionneeds-revisionPaper needs changes before it can proceed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions