Title
References to non-literal types in constexpr functions
Status
c++11
Section
9.2.6 [dcl.constexpr]
Submitter
Daniel Krügler

Created on 2010-09-05.00:00:00 last changed 123 months ago

Messages

Date: 2011-03-15.00:00:00

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

Date: 2010-11-15.00:00:00

Proposed resolution (November, 2010):

  1. Change 6.8 [basic.types] paragraph 10 as follows:

  2. A type is a literal type if it is:

    • a scalar type; or

    • a reference type; or

    • ...

  3. Change 9.2.6 [dcl.constexpr] paragraph 3 as follows:

  4. The definition of a constexpr function shall satisfy the following constraints:

    • it shall not be virtual (11.7.3 [class.virtual])

    • its return type shall be a literal type or a reference to literal type

    • each of its parameter types shall be a literal type or a reference to literal type

    • ...

  5. Change 9.2.6 [dcl.constexpr] paragraph 4 as follows:

  6. The definition of a constexpr constructor shall satisfy the following constraints:

    • each of its parameter types shall be a literal type or a reference to literal type;

    • ...

Date: 2010-11-29.00:00:00

9.2.6 [dcl.constexpr] paragraph 3 is overly restrictive in requiring that reference parameter and return types of a constexpr function or constructor must refer to a literal type. 7.7 [expr.const] paragraph 2 already prevents any problematic uses of lvalues of non-literal types, and it permits use of pointers to non-literal types as address constants. The same should be permitted via reference parameters and return types of constexpr functions.

(See also issue 1194.)

History
Date User Action Args
2014-03-03 00:00:00adminsetstatus: fdis -> c++11
2011-04-10 00:00:00adminsetmessages: + msg3330
2011-04-10 00:00:00adminsetstatus: review -> fdis
2010-11-29 00:00:00adminsetmessages: + msg3085
2010-11-29 00:00:00adminsetstatus: open -> review
2010-09-05 00:00:00admincreate