https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67550
Patrick Palka <ppalka at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |ppalka at gcc dot gnu.org --- Comment #8 from Patrick Palka <ppalka at gcc dot gnu.org> --- (In reply to Jason Wyatt from comment #6) > Adding a TREE_READONLY (to match TREE_READONLY being unset in > split_nonconstant_init) check seems to fix the generated gimple. This is > total guesswork though - I have no idea what side effects this change might > have. > > diff --git a/gcc/cp/init.c b/gcc/cp/init.c > index ac11224..ee0405d 100644 > --- a/gcc/cp/init.c > +++ b/gcc/cp/init.c > @@ -2038,7 +2038,8 @@ constant_value_1 (tree decl, bool strict_p, bool > return_aggregate_cst_ok_p) > || (strict_p > ? decl_constant_var_p (decl) > : (VAR_P (decl) > - && CP_TYPE_CONST_NON_VOLATILE_P (TREE_TYPE (decl))))) > + && CP_TYPE_CONST_NON_VOLATILE_P (TREE_TYPE (decl)) > + && TREE_READONLY (decl)))) > { > tree init; > /* If DECL is a static data member in a template Your fix makes sense to me though I am no expert.