Jason Merrill

Constexpr functions with reference parameters

This wording is revised from the wording in N3039 by Bjarne Stroustrup, Alisdair Meredith and Gabriel Dos Reis; please see that paper for rationale.

The changes in this document are primarily to broaden the allowance to non-const references. Any problematic operation on a non-const reference is still prohibited because it would prevent the function body from being a potential constant expression.

Proposed wording

7.1.5/3, second and third bullets:
7.1.5/4, first bullet:
5.19/2, third bullet:
5.19/2, bullets 6-9:
An expression is a potential constant expression if it is a constant expression when all occurrences of function parameters are replaced as follows:
If the instantiated template specialization of a constexpr function template would fail to satisfy the requirements for a constexpr function or constexpr constructor, the constexpr specifier is ignored.

A call to a constexpr function produces the same result as a call to an equivalent non-constexpr function in all respects except that a call to a constexpr function can appear in a constant expression.