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


1126. constexpr functions in const initializers

Section: 7.7  [expr.const]     Status: C++11     Submitter: GB     Date: 2010-08-02

[Voted into the WP at the November, 2010 meeting.]

N3092 comment GB 25

It does not appear to be clearly enough stated that the example

    constexpr int f() { return 42 + 84; }
    const int sz = f();
    int a[sz];

is equivalent to

    const int sz = 42 + 84;
    int a[sz];

Proposed resolution (August, 2010):

Change 7.7 [expr.const] paragraph 1 as follows:

Certain contexts require expressions that satisfy additional requirements as detailed in this sub-clause; other contexts have different semantics depending on whether or not an expression satisfies these requirements. Such expressions Expressions that satisfy these requirements are called constant expressions. [Note: Those Constant expressions can be evaluated during translation. —end note]