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


898. Declarations in constexpr functions

Section: 9.2.6  [dcl.constexpr]     Status: C++11     Submitter: Daniel Krügler     Date: 9 May, 2009

[Voted into the WP at the March, 2011 meeting as part of paper N3268.]

According to 9.2.6 [dcl.constexpr] paragraph 3, no declarations are permitted in the body of a constexpr function. This seems overly restrictive. At least three kinds of declarations would seem to be helpful in writing such functions: static_assert, typedef and alias declarations, and local automatic variables initialized with constant expressions. (Similar considerations apply to lambdas in which the lambda-return-type-clause is omitted.)

Rationale (July, 2009):

This suggestion needs a proposal and analysis by EWG before it can be considered by CWG.