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

2024-04-18


1626. constexpr member functions in brace-or-equal-initializers

Section: 7.7  [expr.const]     Status: open     Submitter: Daveed Vandevoorde     Date: 2013-02-19

The Standard should make clear that a constexpr member function cannot be used in a constant expression until its class is complete. For example:

  template<typename T> struct C {
    template<typename T2> static constexpr bool _S_chk() {
      return false;
    }
    static const bool __value = _S_chk<int>();
  };

  C<double> c;

Current implementations accept this, although they reject the corresponding non-template case:

  struct C {
    static constexpr bool _S_chk() { return false; }
    static const bool __value = _S_chk();
  };

  C c;

Presumably the template case should be handled consistently with the non-template case.