Hi,

On 09/02/2014 05:45 PM, Jason Merrill wrote:
On 09/02/2014 11:07 AM, Paolo Carlini wrote:
Anyway, what about the below? Certainly works for the tests which we
have got.

Hmm.  This is definitely an improvement, as it allows a subset of

a non-volatile glvalue of literal type that refers to a non-volatile object whose lifetime began within the evalution of e

But it doesn't cover all of that, and in any case we shouldn't need to explicitly handle that just for types with mutable subobjects.

I think perhaps it would be better to remove that hunk as in your initial patch and replace it with a check in constant_value_1 and an explanation in non_const_var_error.
In practice, I'm encountering a rather serious problem with moving away the check, I'm looking more into it, but maybe I can already explain it to you...

The issue, AFAICS, boils down to the difference itself between cxx_eval_outermost_constant_expr and cxx_eval_constant_expression: changing constant_value_1 means that in principle all the calls of the latter (for VAR_DECLs) are impacted. Thus, for example, for the call at the beginning of cxx_eval_component_reference:

struct A
{
  int i;
  mutable int j;
};

constexpr A a = { 0, 1 };
constexpr int i = a.i;

how do we avoid emitting a wrong error for the a of a.i?

Paolo.

Reply via email to