This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/67550] [5/6 regression] Initialization of local struct array with elements of global array yields zeros instead of initializer values
- From: "jwyatt at feralinteractive dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 24 Nov 2015 11:31:00 +0000
- Subject: [Bug c++/67550] [5/6 regression] Initialization of local struct array with elements of global array yields zeros instead of initializer values
- Auto-submitted: auto-generated
- References: <bug-67550-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67550
--- Comment #6 from Jason Wyatt <jwyatt at feralinteractive dot com> ---
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