On 12/10/18 8:48 PM, Marek Polacek wrote:
A template-argument for a non-type template-parameter shall be a converted
constant expression.  But an lvalue-to-rvalue conversion applied to a volatile
glvalue is not allowed to be part of the evaluation of a constant expression.
So this test should be rejected.

It occurred to me after my note on IRC that the potential_constant_expression_1 test we were talking about,

  if (TREE_THIS_VOLATILE (t) && !DECL_P (t))

ought to test want_rval rather than !DECL_P so that we consistently reject the lvalue-to-rvalue conversion, and not other uses of a volatile lvalue. And the diagnostic ought to talk about that rather than "side-effects".

It might still be appropriate to change non_const_var_error, but I'd think it could check TREE_THIS_VOLATILE itself, rather than the caller; I don't see a need for the two calls to differ in their handling of volatile variables.

Perhaps decl_maybe_constant_var_p should return false for constexpr volatile, as well.

Jason

Reply via email to