On 3/29/19 4:25 PM, Marek Polacek wrote:
On Thu, Mar 28, 2019 at 02:55:55PM -0400, Jason Merrill wrote:
On 3/27/19 5:45 PM, Marek Polacek wrote:
Here we have a non-dependent constructor in a template:
{ VIEW_CONVERT_EXPR<const A>(j) }
In digest_init we call massage_init_elt, which calls digest_init_r on the
element. We convert the element, but we're in a template, so
perform_implicit_conversion added an IMPLICIT_CONV_EXPR around it. And then
massage_init_elt calls maybe_constant_init on the element and the usual sadness
ensues.
Only after fold_non_dependent_expr. Perhaps we want a
fold_non_dependent_init?
Yeah, I recall we talked about adding fold_non_dependent_init a year ago.
Using it here works -- in a template, we won't call maybe_constant_*, so
there's no crash.
Bootstrapped/regtested on x86_64-linux, ok for trunk?
2019-03-29 Marek Polacek <pola...@redhat.com>
PR c++/89852 - ICE with C++11 functional cast with { }.
* constexpr.c (fold_non_dependent_expr_template): New static function
broken out of...
(fold_non_dependent_expr): ...here.
(fold_non_dependent_init): New function.
* cp-tree.h (fold_non_dependent_init): Declare.
* typeck2.c (massage_init_elt): Call fold_non_dependent_init instead
of fold_non_dependent_expr. Don't call maybe_constant_init.
@@ -5604,51 +5656,29 @@ fold_non_dependent_expr (tree t,
if (t == NULL_TREE)
return NULL_TREE;
+ if (processing_template_decl)
+ return fold_non_dependent_expr_template (t, complain,
+ manifestly_const_eval);
+ return maybe_constant_value (t, NULL_TREE, manifestly_const_eval);
+}
+tree
+fold_non_dependent_init (tree t,
+ tsubst_flags_t complain /*=tf_warning_or_error*/,
+ bool manifestly_const_eval /*=false*/)
+{
+ if (t == NULL_TREE)
+ return NULL_TREE;
+ if (processing_template_decl)
+ return fold_non_dependent_expr_template (t, complain,
+ manifestly_const_eval);
Don't we still need the maybe_constant_init TARGET_EXPR stripping
behavior in a template?
Jason