We ICE on the following testcase since I've added the SAVE_EXPR-like constexpr handling where the TARGET_EXPR initializer (and cleanup) is evaluated only once (because it might have side-effects like new or delete expressions in it). The problem is if the TARGET_EXPR (but I guess in theory SAVE_EXPR too) initializer is *non_constant_p. We still remember the result, but already not that it is *non_constant_p. Normally that wouldn't be a big problem, if something is *non_constant_p, we only or into it and so the whole expression will be non-constant too. Except in the builtins handling, we try to evaluate the arguments with non_constant_p pointing into a dummy1 bool which we ignore. This is because some builtins might fold into a constant even if they don't have a constexpr argument. Unfortunately if we evaluate the TARGET_EXPR first in the argument of such a builtin and then once again, we don't set *non_constant_p. So, either we don't remember the TARGET_EXPR/SAVE_EXPR result if it wasn't constant, like the following patch does, or we could remember it, but in some way that would make it clear that it is non-constant (e.g. by pushing into the global->values SAVE_EXPR, SAVE_EXPR entry and perhaps for TARGET_EXPR don't remember it on TARGET_EXPR_SLOT, but the TARGET_EXPR itself and similarly push TARGET_EXPR, TARGET_EXPR and if we see those after the lookup, diagnose + set *non_constant_p. Or we could perhaps during the builtin argument evaluation push expressions into a different save_expr vec and undo them afterwards. 2020-03-03 Jakub Jelinek <jakub@redhat.com> PR c++/93998 * constexpr.c (cxx_eval_constant_expression) <case TARGET_EXPR, case SAVE_EXPR>: Don't record anything if *non_constant_p is true. * g++.dg/ext/pr93998.C: New test.
Name |
Last commit
|
Last update |
---|---|---|
.. | ||
ada | Loading commit data... | |
brig.dg | Loading commit data... | |
c-c++-common | Loading commit data... | |
config | Loading commit data... | |
g++.dg | Loading commit data... | |
g++.old-deja | Loading commit data... | |
g++.target | Loading commit data... | |
gcc.c-torture | Loading commit data... | |
gcc.dg | Loading commit data... | |
gcc.dg-selftests | Loading commit data... | |
gcc.misc-tests | Loading commit data... | |
gcc.src | Loading commit data... | |
gcc.target | Loading commit data... | |
gcc.test-framework | Loading commit data... | |
gdc.dg | Loading commit data... | |
gdc.test | Loading commit data... | |
gfortran.dg | Loading commit data... | |
gfortran.fortran-torture | Loading commit data... | |
gnat.dg | Loading commit data... | |
go.dg | Loading commit data... | |
go.go-torture/execute | Loading commit data... | |
go.test | Loading commit data... | |
jit.dg | Loading commit data... | |
lib | Loading commit data... | |
obj-c++.dg | Loading commit data... | |
objc | Loading commit data... | |
objc-obj-c++-shared | Loading commit data... | |
objc.dg | Loading commit data... | |
selftests | Loading commit data... | |
.gitattributes | Loading commit data... | |
ChangeLog | Loading commit data... | |
ChangeLog-1993-2007 | Loading commit data... | |
ChangeLog-2008 | Loading commit data... | |
ChangeLog-2009 | Loading commit data... | |
ChangeLog-2010 | Loading commit data... | |
ChangeLog-2011 | Loading commit data... | |
ChangeLog-2012 | Loading commit data... | |
ChangeLog-2013 | Loading commit data... | |
ChangeLog-2014 | Loading commit data... | |
ChangeLog-2015 | Loading commit data... | |
ChangeLog-2016 | Loading commit data... | |
ChangeLog-2017 | Loading commit data... | |
ChangeLog-2018 | Loading commit data... | |
ChangeLog-2019 | Loading commit data... | |
ChangeLog.graphite | Loading commit data... | |
ChangeLog.jit | Loading commit data... | |
ChangeLog.ptr | Loading commit data... | |
ChangeLog.tree-ssa | Loading commit data... | |
README | Loading commit data... | |
README.compat | Loading commit data... | |
README.gcc | Loading commit data... |