On Wed, Nov 23, 2016 at 11:36 AM, Jakub Jelinek <ja...@redhat.com> wrote: > On Wed, Nov 23, 2016 at 10:42:57AM -0500, Jason Merrill wrote: >> OK, but I wonder why we don't do constant initialization of that variable... > > Dunno either, check_initializer simply returns the call to the constructor > for the var. I've tried something like: > > --- gcc/cp/decl.c.jj 2016-11-21 19:47:06.000000000 +0100 > +++ gcc/cp/decl.c 2016-11-23 17:31:15.963594787 +0100 > @@ -6339,7 +6339,27 @@ check_initializer (tree decl, tree init, > init_code = NULL_TREE; > } > else > - init = NULL_TREE; > + { > + init = NULL_TREE; > + if (TREE_CODE (init_code) == CALL_EXPR) > + { > + tree callee = get_callee_fndecl (init_code); > + /* If INIT_CODE is a call to constexpr ctor, > + see if we can optimize it into a constant > + initialization. */ > + if (callee > + && DECL_DECLARED_CONSTEXPR_P (callee) > + && DECL_CONSTRUCTOR_P (callee) > + && !flag_no_inline) > + { > + init = maybe_constant_value (init_code); > + if (TREE_CODE (init) == CALL_EXPR) > + init = NULL_TREE; > + else > + init_code = NULL_TREE; > + } > + } > + } > } > > if (init && TREE_CODE (init) != TREE_VEC) > > but store_init_value still doesn't like that and turns it into a runtime > initialization. > > So, shall I check the patch in and defer the rest to you, or just defer it?
Go ahead and check it in. Jason