This is the mail archive of the
mailing list for the GCC project.
Re: C++ PATCH for c++/86608, reading constexpr volatile variable
- From: Jason Merrill <jason at redhat dot com>
- To: Marek Polacek <polacek at redhat dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 11 Dec 2018 10:26:00 -0500
- Subject: Re: C++ PATCH for c++/86608, reading constexpr volatile variable
- References: <20181211014841.GQ21364@redhat.com>
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
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
Perhaps decl_maybe_constant_var_p should return false for constexpr
volatile, as well.