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

2025-11-07


3110. Constexpr allocation for literal types

Section: 7.7  [expr.const]     Status: ready     Submitter: Jiang An     Date: 2025-11-01

(From submission #792.)

Consider:

  #include <locale>
  #include <memory>

  static_assert([]{
   auto a = std::allocator<std::locale>{};
   a.deallocate(a.allocate(42), 42);
   return true;
  }());

The type std::locale is not a literal type, yet this is accepted by all implementations.

Proposed resolution (approved by CWG 2025-11-04):

Change in 7.7 [expr.const] paragraph 14 as follows:

For the purposes of determining whether an expression E is a core constant expression, the evaluation of the body of a member function of std::allocator<T> as defined in 20.2.10.2 [allocator.members], where T is a literal type, is ignored.