]> gcc.gnu.org Git - gcc.git/commit
c++: don't do constexpr folding in unevaluated context
authorJason Merrill <jason@redhat.com>
Fri, 5 Nov 2021 04:08:53 +0000 (00:08 -0400)
committerJason Merrill <jason@redhat.com>
Mon, 15 Nov 2021 07:45:48 +0000 (02:45 -0500)
commit4df7f8c79835d56928f51f9e674d326300936e8e
tree7e18a7d480f0c30b44494ef0f15f38e108fc2b11
parent267318a2857a42922c3ca033dac4690172b17683
c++: don't do constexpr folding in unevaluated context

The implicit constexpr patch revealed that we were doing constant evaluation
of arbitrary expressions in unevaluated contexts, leading to failure when we
tried to evaluate e.g. a call to declval.  This is wrong more generally;
only manifestly-constant-evaluated expressions should be evaluated within
an unevaluated operand.

Making this change revealed a case we were failing to mark as manifestly
constant-evaluated.

gcc/cp/ChangeLog:

* constexpr.c (maybe_constant_value): Don't evaluate
in an unevaluated operand unless manifestly const-evaluated.
(fold_non_dependent_expr_template): Likewise.
* decl.c (compute_array_index_type_loc): This context is
manifestly constant-evaluated.
gcc/cp/constexpr.c
gcc/cp/decl.c
This page took 0.058831 seconds and 5 git commands to generate.