commit 6cdd28bb152fcb07a7eb6c9f053cd435cf719a20 Author: Jason Merrill Date: Wed Nov 16 16:13:25 2016 -0500 ref diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index c54a2de..87db589 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -6839,7 +6839,8 @@ cp_finish_decl (tree decl, tree init, bool init_const_expr_p, /* Set these flags now for templates. We'll update the flags in store_init_value for instantiations. */ DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P (decl) = 1; - if (decl_maybe_constant_var_p (decl)) + if (decl_maybe_constant_var_p (decl) + && TREE_CODE (type) != REFERENCE_TYPE) TREE_CONSTANT (decl) = 1; } } diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c index 022a478..dcdb710 100644 --- a/gcc/cp/typeck2.c +++ b/gcc/cp/typeck2.c @@ -824,7 +824,8 @@ store_init_value (tree decl, tree init, vec** cleanups, int flags) const_init = (reduced_constant_expression_p (value) || error_operand_p (value)); DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P (decl) = const_init; - TREE_CONSTANT (decl) = const_init && decl_maybe_constant_var_p (decl); + if (TREE_CODE (type) != REFERENCE_TYPE) + TREE_CONSTANT (decl) = const_init && decl_maybe_constant_var_p (decl); } value = cp_fully_fold (value);